cocos-docs icon indicating copy to clipboard operation
cocos-docs copied to clipboard

docs issue at: 程序化控制动画

Open HelloSakura opened this issue 1 year ago • 1 comments

filePath: zh/animation/animation-component.md content:

//程序化编辑动画剪辑 this.animationClip = new AnimationClip(); const track = new animation.ObjectTrack(); //使用对象轨道

    track.path = new animation.TrackPath().toComponent(Sprite).toProperty('spriteFrame');   //找sprite组件,找对应spriteFrame属性
    //这种切分方式,map??
    //对象轨道只有一条动画曲线,[时间,变化属性]
    const frames:Array<[number, SpriteFrame]> = spriteFrames.map((item:SpriteFrame, index:number)=>[ANIMATION_SPEED*index, item]);
    //影分身是因为把外层的idle也加载进去了,这里去掉
    const subframes = frames.slice(0, frames.length);
    track.channel.curve.assignSorted(subframes);
    //track.channel.curve.assignSorted(frames);

    //轨道添加到动画剪辑以应用
    this.animationClip.addTrack(track);
    this.animationClip.name = this.path;
    
    this.animationClip.duration = frames.length * ANIMATION_SPEED;
    this.animationClip.wrapMode = this.wrapMode;

    for(const event of this.events){
        this.animationClip.events.push(event);
    }
  //this.animationClip.updateEventDatas();

参照文档使用这样方式添加事件帧不会被触发,使用3.3弃用的updateEventDatas才能保证运行过程中触发帧事件,这是操作问题还是其它问题

HelloSakura avatar Dec 03 '24 15:12 HelloSakura

Hello,先发到论坛讨论吧。

MrKylinGithub avatar Dec 25 '24 06:12 MrKylinGithub