Here is an example of using CCSpriteFrameCache and CCSpriteBatchNode.
First, configure the general frame cache (think of it as a mapping between the names of your individual images and their rectangular frames in a combined node package):
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"spritesheet.plist" textureFile:@"spritesheet.png"];
Now create your node batch with a unified image name (this BatchNode makes a single draw for multiple sprites):
CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:@"spritesheet.png" capacity:20];
Now create a sprite node that passes the name of the individual image. Add it to the node package. (Again, batchnode will make calls for a rally, so this is a performance advantage):
CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:@"name_of_your_sprite_in_plist"]; [batchNode addChild:sprite];
You can handle the sprite in the same way as a sprite that you created earlier from a single image (but with performance benefits using the node package).
source share