I'm trying to optimize my game using CCSpriteBatchNode to render multiple sprites at once. However, for some reason cocos2d is giving me this error when I introduce CCSpriteBatchNode as the parent for my sprites:
"CCSprite is not using the same texture id"
I'm confused by this because I have a single 1024x1024 texture atlas with all my graphics. It was created with TexturePacker and without the batch node, it all works. I've been loading it with this:
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"atlas1.plist"];
And now I'm trying to use CCSpriteBatchNode like this:
CCSprite* sprite = [CCSprite spriteWithSpriteFrameName:@"something.png"];
CCSpriteBatchNode* bar = [CCSpriteBatchNode batchNodeWithFile:@"atlas1.png"];
[bar addChild: sprite]; // assert error here
I tried adding some NSLog debug output to cocos2d texture init/lookup code and surprisingly, there are some textures being created with different dimensions (for example 256x256 or even smaller). I don't understand how that can happen when I only have a single 1024x1024 png as the input.
What's happening? How can I debug this?
UPDATE:
Bongeh's answer helped me fix this - made me look twice at everything. There were some stale PNG files from an older version of the game in my iOS simulator that were being loaded, even though they were not in the Xcode project anymore. Doing a "Clean" or even "Clean build folder" from Xcode didn't work but using the "Reset content and settings" command from iOS simulator did the trick. Hooray!