i have some complicated menu, which is built differently every time according to a state.
i have this code :
CCMenuItemSprite *sign = [CCMenuItemSprite itemWithNormalSprite:[CCSprite spriteWithFile:[NSString stringWithFormat:@"image%d.png",[memoryInstnace getCellImageNumber:i]]] selectedSprite:[CCSprite spriteWithFile:[NSString stringWithFormat:@"image%d.png",[memoryInstnace getCellImageNumber:i]]]];
CCMenuItemSprite *playing = [CCMenuItemSprite itemWithNormalSprite:[CCSprite spriteWithFile:@"playing.png"]
selectedSprite:[CCSprite spriteWithFile:@"playing.png"]];
item2=[CCMenuItemToggle itemWithTarget:self selector:@selector(play:)items:sign,playing,nil];
item2.position=pixels[i];
item2.tag=i;
Menu= [CCMenu menuWithItems: item2, nil];
this is a toggle button so when its on A and hitten it comes to B , but i want that some delegate in the app (NOT when someone hit it ) will change the IMAGE of it from B to become A .
i couldnt do setNormalImage to item2.
how can i do that ?
thanks .
Changing the selectedIndex of the CCMenuItemToggle item should do the trick. This will toggle the selected state by negating the current selectedIndex (ie 0 becomes YES and therefore 1 and 1 becomes NO and therefore 0):