This project is read-only.
Simple games can succeed by adding CCSprite instances directly to the main scene. This can work if your sprite count is less than 50. Once you have more than 50 active sprites, you will need to start using CCSpriteBatchNode. To use the CCSpriteBatchNode to manage your sprites, do the following:
CCSpriteBatchNode batch = CCSpriteBatchNode.Create(CCSprite.Create("me").Texture, 50);
AddChild(batch, 1); // Depth again, can be anything

You need to send the texture to the batch node because the batch node uses the texture ID as a requirement for your children. You can't mix sprites in the node, meaning that they all have to derive from the same texture. Now you need to start adding your sprites to the batch node.
batch.AddChild(CCSprite.Create("me"), 1); // Depth can be anything here 

Now you can add thousands of sprites to your game scene and it won't suddenly stop responding to touches. This is especially useful if you are swiping to shoot at targets. Just don't forget to clear out the batch node between levels if you reuse the batch node.

Just remember that your sprite batch nodes can only be homogeneous batches of sprites. The TextureID of the sprites must all be the same, otherwise you lose the performance boost of batching.

Last edited Jan 21, 2014 at 12:44 AM by totallyevil, version 2


Mamadex Nov 26, 2014 at 7:09 PM 
true: CCSprite does not have a static method named Create.

bpnarain May 2, 2014 at 1:55 AM 
CCSprite does not have a static method named Create.