/** * 消除特效 */ let Blast = cc.Class({ extends: cc.Component, editor: { menu:'爆炸效果预制', }, properties: { label: cc.Label, blast: cc.Animation, spriteFrames: [cc.SpriteFrame], }, statics: { pool: cc.NodePool, }, run (score, index) { //分数label this.label.string = score; this.label.node.position = cc.v2(0, 0); this.label.node.opacity = 255; let moveBy = cc.moveBy(0.8, cc.v2(0, 180)); let fadeOut = cc.fadeOut(0.8); this.label.node.runAction(cc.sequence(moveBy, fadeOut)); //爆炸动画 this.blast.play(); this.blast.once(cc.Animation.EventType.FINISHED, () => { Blast.pool.put(this.node); }, this); for(let i = 0; i <= 4; ++i){ let count = i == 0 ? '' : i; let tmp = cc.find('particlesystem' + count, this.blast.node); if(tmp) { let prticle = tmp.getComponent(cc.ParticleSystem); prticle.spriteFrame = this.spriteFrames[index] prticle.resetSystem(); } } }, }); cc.game.on(cc.game.EVENT_GAME_INITED, () => { Blast.pool = new cc.NodePool(); })