加血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

@@ -26,10 +26,13 @@
"_components": [
{
"__id__": 8
},
{
"__id__": 10
}
],
"_prefab": {
"__id__": 10
"__id__": 12
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -224,6 +227,24 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "893nuUmClG0LvnTTvx/hI/"
},
{
"__type__": "9a6c0y9K1tOzYXTwBfeelsq",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 11
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "95QTVE2NFD8400FYKy4ZxR"
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@@ -1,14 +1,30 @@
import { _decorator, Component, Node } from 'cc';
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);
});
}
}
}
update(deltaTime: number) {
onAnimationFinished(){
this.node.active=false
}
}