0

I have a CCMenu that contains CCMenuItemSprite and CCMenuItemLabel. This menu is added to my layer as follows:

[self addChild:itemsMenu];

The menu is always visible to the user and contains objects that can be used by the user himself during the game. For instance, powerups that have limited life. When the player uses the objects, it must be removed from the menu.

Is there a way to delete only a single object in the CCMenu? Or do I have to recreate the full menu?

In my current implementation, I delete menu when the user finishes the number of uses associated to the CCMenuItemSprite with:

[self removeChild:itemsMenu cleanup:YES];
[self removeChild:itemsCountMenu cleanup:YES];

Thanks in advance for the help.

andreapavan
  • 697
  • 1
  • 7
  • 24
  • 1
    You can iterate over the CCMenu's children and remove the item you no longer want. Tag the items to find them more easily. You probably need to re-align the menu's items. – CodeSmile May 12 '13 at 15:13
  • Yes works great, I have to align the menu, Thank you so much :) – andreapavan May 14 '13 at 08:59

0 Answers0