加血buff 动画不关闭原因修复

This commit is contained in:
2025-01-17 16:40:47 +08:00
parent 82d012796f
commit 7a5c3d686e
2 changed files with 52 additions and 15 deletions

View File

@@ -1,14 +1,30 @@
import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('AnmEndCom')
export class AnmEndCom extends Component {
start() {
}
update(deltaTime: number) {
}
}
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.active=false
}
}