I am trying to optimize my game using CCSpriteBatchNode to display multiple sprites at once. However, for some reason, cocos2d gives me this error when I entered CCSpriteBatchNode as the parent for my sprites:
"CCSprite is not using the same texture id"
I am confused because I have one atlas of 1024x1024 texture with all my graphics. It was created using TexturePacker and without the node package, everything works. I downloaded it as follows:
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"atlas1.plist"];
And now I'm trying to use CCSpriteBatchNode as follows:
CCSprite* sprite = [CCSprite spriteWithSpriteFrameName:@"something.png"]; CCSpriteBatchNode* bar = [CCSpriteBatchNode batchNodeWithFile:@"atlas1.png"]; [bar addChild: sprite];
I tried to add some NSLog debugging output to the cocos2d init / lookoc code, and, surprisingly, some textures are created with different sizes (for example, 256x256 or even less). I do not understand how this can happen when I have only 1024x1024 png as input.
What's happening? How can I debug this?
UPDATE:
Bongeh's answer helped me fix this - made me look twice at everything. Some obsolete PNG files from the old version of the game were downloaded in my iOS simulator, although they were no longer in the Xcode project. Running a “clean” or even “clean build folder” from Xcode did not work, but using the “Reset content and settings” command from the iOS simulator did the trick. Hooray!
source share