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 } }