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?
The code above is correct.
The image resource for selection was not added to the project, so was not being displayed. It may have output an error message on creation (buried in other output), but did not output error message when tapped.
The silent/safe failure made the user error harder to track down.