BEffect.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * 子弹击中目标后特效
  3. */
  4. const { ccclass, property } = cc._decorator;
  5. @ccclass
  6. export default class BEffect extends cc.Component {
  7. start() {
  8. // let armature = this.node.getComponent(dragonBones.ArmatureDisplay);
  9. // if(armature){
  10. // armature.addEventListener(dragonBones.EventObject.LOOP_COMPLETE as any ,(event)=>{
  11. // this.node.destroy();
  12. // }, this);
  13. // }
  14. // let nodes = this.node.children
  15. // if(nodes.length > 0){
  16. // let spine = this.node.children[0].getComponent(sp.Skeleton)
  17. // if(spine){
  18. // spine.setCompleteListener(() => {
  19. // this.node.destroy();
  20. // });
  21. // }
  22. // }
  23. // cc.tween(this.node).sequence(
  24. // cc.delayTime(0.5),
  25. // cc.destroySelf())
  26. // .start();
  27. let hurtParticleNode = this.node.getChildByName("liiz_souji");
  28. let hurtParticle: cc.ParticleSystem = null;
  29. if (hurtParticleNode) {
  30. hurtParticle = hurtParticleNode.getComponent(cc.ParticleSystem);
  31. hurtParticle.enabled = true;
  32. }
  33. let spine = this.node.getComponent(sp.Skeleton);
  34. if (spine) {
  35. spine.enabled = true;
  36. spine.setAnimation(0, "hurt", false);
  37. spine.setCompleteListener(() => {
  38. if (hurtParticle) {
  39. hurtParticle.enabled = false;
  40. }
  41. this.node.destroy();
  42. })
  43. }else{
  44. cc.tween(this.node).sequence(
  45. cc.delayTime(0.5),
  46. cc.destroySelf())
  47. .start();
  48. }
  49. }
  50. }