/** * 子弹击中目标后特效 */ const { ccclass, property } = cc._decorator; @ccclass export default class BEffect extends cc.Component { start() { // let armature = this.node.getComponent(dragonBones.ArmatureDisplay); // if(armature){ // armature.addEventListener(dragonBones.EventObject.LOOP_COMPLETE as any ,(event)=>{ // this.node.destroy(); // }, this); // } // let nodes = this.node.children // if(nodes.length > 0){ // let spine = this.node.children[0].getComponent(sp.Skeleton) // if(spine){ // spine.setCompleteListener(() => { // this.node.destroy(); // }); // } // } // cc.tween(this.node).sequence( // cc.delayTime(0.5), // cc.destroySelf()) // .start(); let hurtParticleNode = this.node.getChildByName("liiz_souji"); let hurtParticle: cc.ParticleSystem = null; if (hurtParticleNode) { hurtParticle = hurtParticleNode.getComponent(cc.ParticleSystem); hurtParticle.enabled = true; } let spine = this.node.getComponent(sp.Skeleton); if (spine) { spine.enabled = true; spine.setAnimation(0, "hurt", false); spine.setCompleteListener(() => { if (hurtParticle) { hurtParticle.enabled = false; } this.node.destroy(); }) }else{ cc.tween(this.node).sequence( cc.delayTime(0.5), cc.destroySelf()) .start(); } } }