你好。关于动画事件,如果希望监听动画最后一帧播放完成的事件,应该监听 AnimationComponent.EventType.LASTFRAME
而非 AnimationComponent.EventType.FINISHED
:
const animationComponent = this.node.getComponent(AnimationComponent);
// 推荐的做法:
const state = animationComponent.getState('mixamo.com');
animationComponent.on(AnimationComponent.EventType.LASTFRAME, (type, state) => {
console.log(`State finished.`);
});
AnimationComponent.EventType.FINISHED
仅当动画停止之后才会触发,这包括:
- 当动画仅播放一次并且播放到自然停止时。