iphoneobjective-ccocos2d-iphoneccmenuitem

Dynamic CCMenu with Cocos2d


I wanted to create a menu in cocos2d in which the menu items would drift through the screen, disappear, and then re-appear. I haven't been able to find anything that showed the CCMenuItem's animating, or moving. Is this possible to do? Or would I be better to use CCSprites and just create functions to switch scene's when they are touched?


Solution

  • You can use CCMenuItemSprite (a subclass of CCMenuItem) to achieve this. Go ahead and create your sprites (and apply actions to them if you like) and then use those sprites to create the CCMenuItemSprite. But if you want to change the actions later, you'll need to hang on to a pointer to the CCSprite--that's what controls the action (not the CCMenuItemSprite).