Search code examples
ioscocos2d-iphonetexturesccspriteframe-rate

What is the best approach for CCSpriteBatchNode and texture sheets in a Cocos2D game scene


I am modifying some tutorials I found on Learn Cococs2D and found that whenver I use more than one CCSpriteBatchNode in one class the frame rate drops.

Reading a bit around I understood that one CCSpriteBatchNode can accept only 1 texture sheet at a time and this poses some limitations on the level design (sprite sheet can be max 2048x2048 pixels discussion). Although there are some extensions that seem to overcome this limitaton (which I haven't yet dared to try) CCBigImage.

I am trying to following the one file approach and load all my images in one CCSpriteFrameCache but I haven't found much on programming guides about this.

In the ShootEmUp example of 1 the approach is to have a CCSpriteBatchNode in ParallaxNode as well as in other classes such as EnemyCache (find source on folder Chapter 8 on link book source code link)

Although I have researched a bit on the cocos2d-iphone.org forums and found the following topic where a moderator suggests to add only one instance of CCSpriteBatchNode to the root layer forum topic.

I am now a bit confused. The one thing I noticed is that following the 1 approach (multiple instances) the frame rate is not optimal. Have you similar experiences and how do you tackle this?

Multiple CCSpriteBatchNode or not? One texture sheet per level or multiple?

Thanks a lot for reading :)


Solution

  • I don't think your issue with frame rate is due to multiple CCSpriteBatchNode's... I have used more then one CCSpriteBatchNode in a class and I doubt this is the issue. You can only have one CCSpriteFrameCache though. You might need to post some code to get to the bottom of the issue