how to embeed multiple sprite sheet CCSpriteFrameCache animation in cocos2d
all
I want to embeed multiple spriteFrame cache using the following code.
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"abc.plist"];
// Create a sprite sheet with the Happy Bear images
CCSpriteBatchNode *spriteSheet =开发者_JAVA技巧 [CCSpriteBatchNode batchNodeWithFile:@"abc.png"];
[self addChild:spriteSheet];
the problem is that after 1st animation is cover I want to do another animation through another ccsprite fram cache, and add another sprite sheet, but when I add another sprite sheet it will give me sigerbat error.
how can I do multiple animation after one animation cover then the second animation will start, remember that there are 4 CCSpriteFrameCache file (ie,. 4 plist file)
All CCSprite added to a CCSpriteBatchNode must use the same texture. So what you're trying to accomplish is not possible because you're trying to add images from 4 different textures. If you check the Console (in Debug builds) you'll find a message stating something to that effect.
The solution: use one CCSpriteBatchNode for each texture (loaded via CCSpriteFrameCache plist). You'll have to write more code but that's the only way you can do it, apart from not using CCSpriteBatchNode at all.
You might want to do a performance test to check if you really, really need the CCSpriteBatchNode. For example, if you only display ONE sprite from the same texture on screen at any one time, you don't need a CCSpriteBatchNode. It's only improving performance if you have multiple (and many) sprites on screen and all are using the same texture.
精彩评论