Files
heros/assets/script/game/skills/EndAnmBomCom.ts
2025-01-13 10:43:23 +08:00

46 lines
1.7 KiB
TypeScript

import { _decorator, Animation, Collider2D, Component, Node, sp } from 'cc';
import { SkillCom } from './SkillCom';
import { BoxSet } from '../common/config/BoxSet';
import { Hero } from '../hero/Hero';
const { ccclass, property } = _decorator;
@ccclass('EndAnmBomCom')
export class EndAnmBomCom extends Component {
time:number = 0
base:SkillCom = null
collider:Collider2D = null
start() {
this.base =this.node.getComponent(SkillCom)
this.collider = this.getComponent(Collider2D);
console.log("collider",this.collider)
if(this.base.box_group ==BoxSet.HERO) this.collider.group = BoxSet.MONSTER
if(this.base.box_group ==BoxSet.MONSTER) this.collider.group = BoxSet.HERO
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.collider.group = this.base.box_group
this.node.active=false
this.node.active=true
this.base.is_destroy = true
}
}