Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs issue at: 程序化控制动画 #3083

Open
HelloSakura opened this issue Dec 3, 2024 · 1 comment
Open

docs issue at: 程序化控制动画 #3083

HelloSakura opened this issue Dec 3, 2024 · 1 comment

Comments

@HelloSakura
Copy link

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才能保证运行过程中触发帧事件,这是操作问题还是其它问题

@MrKylinGithub
Copy link
Contributor

Hello,先发到论坛讨论吧。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants