cocos2d-js飞机项目:飞机爆炸效果


1.首先把plist文件加载上来
cc.spriteFrameCache.addSpriteFrames(res.exp_1);     
2.把图片分开依次存在数组中
var mExplodeFrames = [];
for(var i= 1;i< 17;i++){
    var frame = cc.spriteFrameCache.getSpriteFrame("explosion_"+("00"+i).slice(-2)+".png")
    mExplodeFrames.push(frame);
}
3.把动作添加到一个空的Sprite上执行
var anim = new cc.Animation(mExplodeFrames,0.04);
var that = this;
this._listener = cc.eventManager.addCustomListener(GAME_EVENT.PLANE_BOMB,function(event){
    var target = event.getUserData();
    var sp = new cc.Sprite();
    //var sp = new cc.ParticleSystem("res/BoilingFoam.plist");
    sp.setPosition(target);
    that.addChild(sp);
    sp.scale = Math.random()*2;
    sp.runAction(cc.sequence(cc.animate(anim),cc.fadeOut(0.1)))
});


你可能感兴趣的:(js)