Files
pixelheros/assets/script/game/skill/oncend.ts
panw 0f6ab4a775 refactor(skill): 优化特效生命周期管理并添加新动画
- 移除 timedCom 组件中未使用的 cd 和 ap 属性
- 重命名 dead 组件为 oneCom 并重构动画结束销毁逻辑,避免内存泄漏
- 为部分技能添加准备动画(readyAnm)配置
- 新增 uplv 升级动画特效预制体
- 统一特效生成接口,支持基于动画结束或定时销毁两种模式
- 清理 HeroViewComp 中未使用的导入和方法
2026-03-19 14:40:51 +08:00

30 lines
760 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) return;
this.anim.off(Animation.EventType.FINISHED, this.onAnimationFinished, this);
this.anim = null;
}
onAnimationFinished() {
this.node.destroy();
}
}