import PoolMgr, { NODEPOOLPREFABTYPE } from "../../mgr/PoolMgr"; const { ccclass, property } = cc._decorator; @ccclass export default class AniFinishDestroy extends cc.Component { private ani: cc.Animation = null; private callBack: Function = null; // LIFE-CYCLE CALLBACKS: onLoad() { this.ani = this.node.getComponent(cc.Animation); this.ani.on('finished', this.onAniPlayFinished, this); } start() { } // update (dt) {} init(callBack: Function = null) { if (!this.ani) { this.ani = this.node.getComponent(cc.Animation); this.ani.on('finished', this.onAniPlayFinished, this); } this.callBack = callBack; this.ani.play(); } onAniPlayFinished() { if (this.callBack) { this.callBack(); } this.recycle(); } recycle() { PoolMgr.Inst.recyclePoolPrefab(NODEPOOLPREFABTYPE[this.node.name], this.node); } }