求教代码创建动画打包到微信小游戏的问题

  • Creator 版本: 3.6.2

  • 目标平台:微信小游戏开发工具

  • 重现概率: 100%重现

各位大佬好,我在代码里动态创建了动画,代码如下:

     let texturePath = 'texture/ultimateskill/ultimateskill0'

    const nodeAnimation = this.node.addComponent(Animation)

    const promise = ResourceManager.Instance.loadDir(texturePath)

    const spriteFrames = await promise;

    spriteFrames.splice(spriteFrames.length - 1, 1)

    const animationClip = new AnimationClip()

    const track = new animation.ObjectTrack()

    track.path = new animation.TrackPath().toComponent(Sprite).toProperty('spriteFrame')

   

    const frames: Array<[number, SpriteFrame]> = spriteFrames.map((item, index) => [index / 24, item])


    track.channel.curve.assignSorted(frames)

    animationClip.addTrack(track)

    animationClip.name = 'explosion'

    animationClip.wrapMode = AnimationClip.WrapMode.Loop

    animationClip.duration = frames.length * 1 / 24

    nodeAnimation.defaultClip = animationClip

    nodeAnimation.play()

在浏览器中预览是正常的:

QQ录屏2023050415303100_00_02--00_00_22
但打包到微信小游戏后,明显感觉帧数加快了:
QQ录屏2023050415305800_00_02--00_00_22

可能gif无法很好地展现,最大的感觉就是动画循环一次的时间明显变少了。
我尝试了将动画的每秒24帧降到了12帧,但明显感觉又有点卡顿,请问造成这个问题的根源是什么?应该怎么解决呢。
Any comments and suggestion are always welcome.

1赞

根源是我没有对帧动画的顺序进行严谨的排序,在浏览器跟微信预览里效果不一样。我自己的问题。抱歉。

1赞