Files
heros/assets/script/game/skills/AnmEndCom.ts

31 lines
1.0 KiB
TypeScript

import { _decorator, Animation, Component, Node, sp } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('AnmEndCom')
export class AnmEndCom extends Component {
start() {
if(this.node.getComponent(Animation)){
let anim = this.node.getComponent(Animation);
console.log("has anim",anim)
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
}
if(this.node.getChildByName('anm')){
if(this.node.getChildByName('anm').getComponent('sp.Skeleton')){
var spine = this.node.getChildByName('anm').getComponent('sp.Skeleton') as sp.Skeleton;
console.log("has spine",spine)
spine.setCompleteListener((trackEntry) => {
this.onAnimationFinished()
console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex);
});
}
}
}
onAnimationFinished(){
this.node.destroy()
}
}