From 7a5c3d686ec1d6e7383f0a1221897c8a099ea970 Mon Sep 17 00:00:00 2001 From: walkpan Date: Fri, 17 Jan 2025 16:40:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E8=A1=80buff=20=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E4=B8=8D=E5=85=B3=E9=97=AD=E5=8E=9F=E5=9B=A0=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/resources/game/skills/heathed.prefab | 23 ++++++++++- assets/script/game/skills/AnmEndCom.ts | 44 ++++++++++++++------- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/assets/resources/game/skills/heathed.prefab b/assets/resources/game/skills/heathed.prefab index ef223521..3c5b185a 100644 --- a/assets/resources/game/skills/heathed.prefab +++ b/assets/resources/game/skills/heathed.prefab @@ -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": { diff --git a/assets/script/game/skills/AnmEndCom.ts b/assets/script/game/skills/AnmEndCom.ts index a99fb3df..19cb5470 100644 --- a/assets/script/game/skills/AnmEndCom.ts +++ b/assets/script/game/skills/AnmEndCom.ts @@ -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 + } +} + +