2012-10-10 14:50:04 +08:00
|
|
|
var Explosion = cc.Sprite.extend({
|
|
|
|
tmpWidth:0,
|
|
|
|
tmpHeight:0,
|
|
|
|
ctor:function () {
|
|
|
|
// needed for JS-Bindings compatibility
|
|
|
|
cc.associateWithNative( this, cc.Sprite );
|
|
|
|
|
|
|
|
var pFrame = cc.SpriteFrameCache.getInstance().getSpriteFrame("explosion_01.png");
|
|
|
|
this.initWithSpriteFrame(pFrame);
|
|
|
|
|
|
|
|
var cs = this.getContentSize();
|
|
|
|
this.tmpWidth = cs.width;
|
|
|
|
this.tmpHeight = cs.height;
|
|
|
|
|
|
|
|
var animation = cc.AnimationCache.getInstance().getAnimation("Explosion");
|
|
|
|
this.runAction(cc.Sequence.create(
|
|
|
|
cc.Animate.create(animation),
|
2012-11-05 23:22:59 +08:00
|
|
|
cc.CallFunc.create(this.destroy, this)
|
2012-10-10 14:50:04 +08:00
|
|
|
));
|
|
|
|
this.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
|
|
|
|
},
|
|
|
|
destroy:function () {
|
2012-11-05 23:22:59 +08:00
|
|
|
this.getParent().removeChild(this);
|
2012-10-10 14:50:04 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Explosion.sharedExplosion = function () {
|
|
|
|
cc.SpriteFrameCache.getInstance().addSpriteFrames(s_explosion_plist);
|
|
|
|
var animFrames = [];
|
|
|
|
var str = "";
|
|
|
|
for (var i = 1; i < 35; i++) {
|
|
|
|
str = "explosion_" + (i < 10 ? ("0" + i) : i) + ".png";
|
|
|
|
var frame = cc.SpriteFrameCache.getInstance().getSpriteFrame(str);
|
|
|
|
animFrames.push(frame);
|
|
|
|
}
|
|
|
|
var animation = cc.Animation.create(animFrames, 0.04);
|
|
|
|
cc.AnimationCache.getInstance().addAnimation(animation, "Explosion");
|
|
|
|
};
|