在2.0.7版本中伪代码如下:
protected onLoad() {
try {
this.aniHero.on(“finished”, this.onAnimationFinished, this);
} catch (err) {
logger.error([Hero.onLoad] ${err.stack || err.message});
}
}
private onAnimationFinished(type: string, state: cc.AnimationState) {
// 逻辑代码
}
然后在注册事件那段代码this.onAnimationFinished会提示错误:类型“(type: string, state: AnimationState) => void”的参数不能赋给类型“(event: string) => void”的参数。
查看creator.d.ts关于on的定义:on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
发现callBack中的参数类型是cc.Event.EventCustom,但是我查看api文档发现动画提供的注册事件回调函数的参数是(type: string, state: cc.AnimationState),请问各位大神,如何消除这个报错提示。

