I’m trying to figure out how the Sprite sheets work. I found in a tutorial this code :
CCSpriteBatchNode *backgroundBgNode; backgroundBgNode = [CCSpriteBatchNode batchNodeWithFile:@"background.pvr.ccz"]; [self addChild:backgroundBgNode]; [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"background.plist"]; CCSprite *background = [CCSprite spriteWithSpriteFrameName:@"MuleDeer-ipadhd.png"]; background.anchorPoint = ccp(0,0); [backgroundBgNode addChild:background];
Basically this code is clear but suppose that I have multiple spritesheets (pvr.czz files) and that every spritesheet has hundreds of different sprites. As suggested by the previous code I should add as a child every sprite to his corresponding CCSpriteBatchNode. Basically the problem is that the tool I use to generate spritesheets will almost randomly fit the sprites in different spritesheets if all the sprites do not fit in 1 spritesheet. What I have is a list of all the files (sprites) and I don’t know exactly to which spriteSheet they belong. So is there a way to get from code the right CCSpriteBatchNode to whom I should add my generating sprites ?