I don’t understand what I do when I add CCSpriteFrameCache or CCSpriteBatchNode to my cocos2d application. Can someone explain the following points (it would be useful if you could explain a few, please write an appropriate letter before answering in accordance with the question you are answering):
[all questions imply achieving the best performance and least memory usage]
a) Is it important to create sprites for each layer? (For example: Menu - own sprite, GameLayer - own sprite ...)
b) Can someone explain why I have to add sprites to the bundled version of node, and what is a node package?
b1) So, why can't I just do something like:
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"menusprites.plist"]; CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"menusprites.png"]; [self addChild:spriteSheet];
And then just add sprites to my layer, calling
CCSprite *mySprite = [CCSprite spriteWithSpriteFrameName:@""]; [self addChild:mySprite];
without adding them to the node package? Because from what I understand, it works as follows:
I add my sprite with all the sprites on it to the screen. Then my application goes into plist and looks for the coordinates of the sprite that I want to display, and then puts it on the screen. So why should I call
[spriteSheet addChild:mySprite]
?
c) How can I get rid of sprites for memory purposes when I no longer need it?
objective-c ipad cocos2d-iphone ccsprite
the_critic
source share