- 在多个组件的onDestroy方法中添加节点有效性检查,防止无效节点上解绑事件 - 修复MissionComp中任务启动逻辑,改为通过UI打开方式触发MissionStart事件 - 添加新的任务界面(UIID.Mission)及相关配置 - 修复MissionCardComp中Map未初始化导致的空引用问题 - 优化按钮事件绑定和解绑逻辑,增加空值检查
31 lines
788 B
TypeScript
31 lines
788 B
TypeScript
import { _decorator, Component, Animation } from 'cc';
|
|
const { ccclass } = _decorator;
|
|
|
|
@ccclass('oneCom')
|
|
export class oneCom extends Component {
|
|
private anim: Animation | null = null;
|
|
|
|
start() {
|
|
this.anim = this.node.getComponent(Animation);
|
|
if (!this.anim) {
|
|
this.node.destroy();
|
|
return;
|
|
}
|
|
this.anim.off(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
|
this.anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
|
}
|
|
|
|
onDestroy() {
|
|
if (this.anim && this.anim.isValid) {
|
|
this.anim.off(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
|
}
|
|
this.anim = null;
|
|
}
|
|
|
|
onAnimationFinished() {
|
|
this.node.destroy();
|
|
}
|
|
}
|
|
|
|
|