8cda5e47-143b-454c-9131-b23914534200.js 1.3 KB

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