I wanted to ask on how to use a sprite packed into multiple sprite sheets (multipack in texturePacker). I tried this but it doesn't work:
var bgCrumbleLayer = cc.Layer.extend({
crumbleSheet_0:null,
crumbleSheet_1:null,
crumbleSheet_2:null,
crumbleSheet_3:null,
crumbleAction:null,
crumbleSprite:null,
ctor:function () {
this._super();
this.init();
},
init:function () {
this._super();
var winSize = cc.winSize;
// create sprite sheet
cc.spriteFrameCache.addSpriteFrames(res.crumble_0_plist);
cc.spriteFrameCache.addSpriteFrames(res.crumble_1_plist);
cc.spriteFrameCache.addSpriteFrames(res.crumble_2_plist);
cc.spriteFrameCache.addSpriteFrames(res.crumble_3_plist);
this.crumbleSheet_0 = new cc.SpriteBatchNode(res.crumble_0_png);
this.crumbleSheet_1 = new cc.SpriteBatchNode(res.crumble_1_png);
this.crumbleSheet_2 = new cc.SpriteBatchNode(res.crumble_2_png);
this.crumbleSheet_3 = new cc.SpriteBatchNode(res.crumble_3_png);
this.addChild(this.crumbleSheet_0);
this.addChild(this.crumbleSheet_1);
this.addChild(this.crumbleSheet_2);
this.addChild(this.crumbleSheet_3);
// init runningAction
var crumbleFrames = [];
for (var i = 0; i < 104; i++) {
//var str = "crumble_" + (i < 10 ? ("0" + i) : i < 100 ? ("0" + i) : i) + ".png";
if(i < 10){
str = "crumble_00" + i + ".png";
}else if(i < 100){
str = "crumble_0" + i + ".png";
}else {
str = "crumble_" + i + ".png";
}
var frame = cc.spriteFrameCache.getSpriteFrame(str);
crumbleFrames.push(frame);
}
var crumbleAnimation = new cc.Animation(crumbleFrames, 0.1);
this.crumbleAction = new cc.repeat(new cc.Animate(crumbleAnimation), 1);
this.crumbleSprite = new cc.Sprite("#crumble_000.jpg");
this.crumbleSprite.attr({
x: winSize.width/2,
y: winSize.height/2
});
this.crumbleSheet_0.addChild(this.crumbleSprite);
this.crumbleSheet_1.addChild(this.crumbleSprite);
this.crumbleSheet_2.addChild(this.crumbleSprite);
this.crumbleSheet_3.addChild(this.crumbleSprite);
this.crumbleSprite.runAction(this.crumbleAction);
}
});
Can you please advise?