Blast.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * 消除特效
  3. */
  4. let Blast = cc.Class({
  5. extends: cc.Component,
  6. editor: {
  7. menu:'爆炸效果预制',
  8. },
  9. properties: {
  10. label: cc.Label,
  11. blast: cc.Animation,
  12. spriteFrames: [cc.SpriteFrame],
  13. },
  14. statics: {
  15. pool: cc.NodePool,
  16. },
  17. run (score, index) {
  18. //分数label
  19. this.label.string = score;
  20. this.label.node.position = cc.v2(0, 0);
  21. this.label.node.opacity = 255;
  22. let moveBy = cc.moveBy(0.8, cc.v2(0, 180));
  23. let fadeOut = cc.fadeOut(0.8);
  24. this.label.node.runAction(cc.sequence(moveBy, fadeOut));
  25. //爆炸动画
  26. this.blast.play();
  27. this.blast.once(cc.Animation.EventType.FINISHED, () => {
  28. Blast.pool.put(this.node);
  29. }, this);
  30. for(let i = 0; i <= 4; ++i){
  31. let count = i == 0 ? '' : i;
  32. let tmp = cc.find('particlesystem' + count, this.blast.node);
  33. if(tmp) {
  34. let prticle = tmp.getComponent(cc.ParticleSystem);
  35. prticle.spriteFrame = this.spriteFrames[index]
  36. prticle.resetSystem();
  37. }
  38. }
  39. },
  40. });
  41. cc.game.on(cc.game.EVENT_GAME_INITED, () => {
  42. Blast.pool = new cc.NodePool();
  43. })