I have this declared on my main class:
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"atlas.plist"];
CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:@"atlas.png"];
now I am on another class and I want to create a new batchNode but get spriteFrames from atlas, that was declared on the main class. How do I do that? Do I need to put these same lines again on my other class? By doing so, will I have redundant images imported to the sharedSpriteFrameCache? My idea is to save memory, not wasted.
Any clues? thanks.
You don’t need to call
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"atlas.plist"];again assuming you haven’t removed these sprite frames.You will need to create another batch node to put sprites on.
If you were to try and add the sprite frames to the cache again, you wouldn’t waste space, the sprite frames would only be added once, but you would waste time while cocos2D parses through the file and determines if each sprite frame has indeed already been added.