can you create a new CCSprite from a part of a CCSprite within a CCSpriteBatchNode?
For a long time, I've used SpriteFrameCache and BatchNode without a 100% understanding of the two, in particular how they relate to the textureCache. I could use some clear advice to accomplish the following:
Currently, I load a texture atlas into CCSpriteBatchNode and the frame list into the CCSpriteFrameCache and generate a sprite in what I think is basic standard fasion
CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:@"textureAtlasImage.png"];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"textureAtlasFrames.plist"];
CCSprite * gameObject = [CCSprite spriteWithSpriteFrameName:@"gameObject.png"];
[self addChild:batchNode];
[batchNodeaddChild:gameObject];
For the sake of simplicity with the question, What I'd like to do is divide gameObject into 4 pieces programatically (rather than divide the original image into four pieces and adding each into the textureAtlasImage.png individually).
From reading, I'm thinking something like:
CCSpriteFrame * gameObjectFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"textureAtlasFrames.plist"];
CCTexture2D * gameObjectIndividualTexture = [[gameObjectFrame] texture];
CCSpriteFrame * gameObjectPartFrame = [CCSpriteFrame frameWithTexture:gameObjectIndividualTexture offset: rectInPixels: ] ;
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFrame:gameObjectPartFrame name:@"gameObjectPart1"];
But my questions then are: Is this already in the batchNode? If not, how do I actually create the sprite out of the gameObjectPart1 using batchNodes? Is it wasteful to add another spriteframe to the cache that duplicates data elsewhere?