Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.81 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. cocos2d maintain a ccmenuitem list
  2. NSMutableArray *listOfItems;
  3.     Items *items = [ItemParser loadItemsForALevel:selectedLevel fromASuperLevel:selectedSuperLevel];
  4.        
  5. for (Item *item in items.items) {
  6.  
  7. //Initialing a CCMenuItem and calling a removeMethod
  8. CMenuItem *anItem = [[CCMenuItemSprite itemFromNormalSprite:[CCSprite spriteWithFile:item.picture]
  9.  selectedSprite:[CCSprite spriteWithFile:item.picture]
  10. target:self
  11. selector:@selector(removeMethod:)] retain];
  12.  
  13. NSString *textToDisplay;
  14. textToDisplay = item.ItemText;
  15. [listOfItems addObject:textToDisplay];
  16.  
  17. }
  18.  
  19. -(void)removeMethod:(id)sender {
  20. CCMenuItemSprite *pointedItem = (CCMenuItemSprite *)sender;
  21.  
  22. //Now I'm removing only from the layer
  23. [CCCallFunc actionWithTarget:pointedItem selector:@selector(removeFromParentAndCleanup:)]
  24.  
  25. //How do I remove it from array?
  26.  
  27. }