CocosCreator3播放动画偏移的解决方案

我在设计这个单位的开火的时候,发现他的开火动画有时候会跑偏

在这里插入图片描述

下面是正常情况
在这里插入图片描述

下面是异常情况

在这里插入图片描述

我个人怀疑是因为动画播放的图中 单位有移动 然后图像就定个在一个位置了

解决方案就是重新载入一下图像就好

  /**播放开火动作 */
    PlayFireAnimation() {
    
    
        if (this.ShotFireAnimation.length > 0) {
    
    
            for (let i of this.ShotFireAnimation) {
    
    
                i.node.getComponent(Sprite).enabled = false
                i.node.getComponent(Sprite).enabled = true

                let name = i.clips[0].name
                i.stop()
                i.play()
            }
        }

    }

解决完毕!

猜你喜欢

转载自blog.csdn.net/Yourset/article/details/126533815