Considering create CCMenuItemImage with single image/spritesheet file ?

Considering create CCMenuItemImage with single image/spritesheet file ?
0.0 0


I came across using CCMenuItemImage and found that the underlying method calls refer to individual loading of texture for different stages.

I would believe it will gain some performance (not so sure about this) + reduce memory usage (instead of multiple files but one).

That’s just my thought, I think you guys already considered this kind of thing. Thanks !


Do you mean the 3 individual loading phase for normal/selected/disabled ones?


Yes Walzer


OK. You can optimize like this

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Menus.plist", "Menus.png");
CCMenuItemSprite *item = CCMenuItemSprite::itemFromNormalSprite(
                                            CCSprite::spriteWithSpriteFrameName("menu-normal.png"); //menu-normal.png is packed in Menus.plist & Menus.png
                                            menu_selector(MyLayer::menuCallback) );

The theory is to load packed plist & png into CCSpriteFrameCache, then create sprites from this cache, use these sprites in CCMenuItemSprite. Current APIs can do this as you wish, but we need to type in more characters.