Laya3D动画倒放后会循环播放的问题

Laya3D动画倒放后会循环播放的问题

问题详情:在animator.speed设置为负数(即反向播放时),动画会循环播放
类库版本:2.6.1
解决方法:修改bin/laya.d3.js文件,找到_updatePlayer方法

_updatePlayer(animatorState, playState, elapsedTime, islooping) {
            var clipDuration = animatorState._clip._duration * (animatorState.clipEnd - animatorState.clipStart);
            var lastElapsedTime = playState._elapsedTime;
            var elapsedPlaybackTime = lastElapsedTime + elapsedTime;
            playState._lastElapsedTime = lastElapsedTime;
            playState._elapsedTime = elapsedPlaybackTime;
            var normalizedTime = elapsedPlaybackTime / clipDuration;
            playState._normalizedTime = normalizedTime;
            var playTime = normalizedTime % 1.0;
            playState._normalizedPlayTime = playTime < 0 ? playTime + 1.0 : playTime;
            playState._duration = clipDuration;
            var scripts = animatorState._scripts;
            // 修改后代码 [修复动画倒放后会循环播放的bug 2021年3月11日14:05:02]
            if(!islooping){
                if(elapsedPlaybackTime>0){
                    if(elapsedPlaybackTime >= clipDuration){
                        playState._elapsedTime = clipDuration;
                        playState._normalizedPlayTime = 1.0;
                    }
                }else{
                    playState._elapsedTime = 0;
                    playState._normalizedPlayTime = 0.0;
                }
                if (scripts) {
                    for (var i = 0, n = scripts.length; i < n; i++)
                        scripts[i].onStateExit();
                }
                return;
            }
            //以下是原代码
            /* if ((!islooping && elapsedPlaybackTime >= clipDuration)) {
                playState._finish = true;
                playState._elapsedTime = clipDuration;
                playState._normalizedPlayTime = 1.0;
                if (scripts) {
                    for (var i = 0, n = scripts.length; i < n; i++)
                        scripts[i].onStateExit();
                }
                return;
            } */
            if (scripts) {
                for (i = 0, n = scripts.length; i < n; i++)
                    scripts[i].onStateUpdate();
            }
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值