The documentation for CCMenuItemImage doesn't actually say what it does.
There are quite a few subclass CCMenuItem. I've inherited a project that's using it as a button.
CCMenuItem *start;
start = [CCMenuItemImage itemFromNormalImage:[self prefixedImage:@"start button.png"]
selectedImage:[self prefixedImage:@"start button selected.png"]
target:myTarget
selector:@selector(start:)];
It was using the same button for both states. I modified it to have a different image for the selected state.
I was expecting/hoping that when I touch the item it will be highlighted, and when I release the button it will send my target action (which it does).
(aside: in iOS parlance, i know that highlighted and selected are two different things. But this library does not seem to have that difference.)
So:
- Is it intended to use this "menu item" as a button?
- When is the selected image of this menu item displayed?
- How should I go about making it display as selected?
CCMenuItem is an abstract class from which all of the other menu items inherit so what you did there in the code is technically wrong.
On the other hand you could subclass CCMenuItem to make your own custom class (for example: you can't use a button and a label on it as a menu item, you have to use either the button itself and the label is on top..just for show, or use the label and the button below is...pointless)
Subclassing CCMenuItem and making your own class would fix that problem (i mean you could make a method that would take an image and a string and returns a button)
What you want to do there is this:
When you put your finger on the menu it will replace the normal image with the selected one, but will only activate of you release it in the boundingbox of the button (aka..you can press on the button, move your finger away from the button and it wont activate). So in a sence the button is highlighted untill you release your finger, then its selected.
Did that answer your question?