动态创建AnimationClip的回调

我想问一下这个回调函数在哪里声名、怎么触发?
目前我在函数内部定义如下图1
企业微信截图_16503714227867
以及外部生命周期定义方法如下图2都不管用
企业微信截图_16503714332688

callback will triggered when it place in class has the same of node with cc.Animation component.
image

1赞


我看了3.4版本的文档,给出的示例如上图,这里是不是一定要在动画编辑器里添加事件帧才有效果呢?但是目前我是在全部在脚本上执行,不希望还要在动画编辑器上编辑。

No, you don’t need.

May be you has push many call back.
Let try to set : clip.events[0] = {frame : 1, func: “frameEvent”, params : [“xxx”]}

Print clip to see that the callback already exists, but I don’t know how to trigger it now.

企业微信截图_16504232767029

let’s show your class here :slight_smile:


This script is mounted on the outermost canvas, not on the animation container node

Oh, i see :slight_smile:
Let’s try to add event before you addClip :slight_smile:

Tried it, still no effect

Wrap_node must be = this.node.

It works, but I want to add it to different animation container nodes, so this callback feels a bit tasteless

Create a class with callback function, and then add class to that container node.

Yep.I will try it tomorrow. Anyway,thanks so much.

“Add a class to this container node”, can you elaborate on this? I guess it may be necessary to add script components to each container node and then introduce class

node.addComponent(YourClass);

It’s totally fine, just know that you can add classes as node components, thank you so much.

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。