Using a menu button, but it only works when I release it?

Using a menu button, but it only works when I release it?
0.0 0


I’m using a menu button for one of my game buttons.
The button is supposed to apply a force to my player when it is pushed (basically just run a function via a callback).

The thing though is…it only works after I release it.
How do I make it so, it only works right after I press it?

pCloseItem = CCMenuItemImage::itemFromNormalImage(
menu_selector(HelloWorld::jumpCallback) );

// create menu, it’s an autorelease object
pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
this~~>addChild(pMenu, 1); @


Try this, create a sub-class and implement the selected* and/orunselected()* methods.


I derived it…but nothing happens when I click it?


CCLog never outputs me anything, on linux and android. I just quickly throw up a dirty label usually.


I’m using win32.


Make sure that you’re creating a Button, not a CCMenuItem.

Button::itemFromNormalImage(…) will not return a Button unless you override it to create a Button object.

Button* item = Button::itemFromNormalImage(…);

//This won’t work if you did not override the method to return a Button* instead
CCMenuItemImage* item = Button::itemFromNormalImage(…);

CCMenuItemImage::selected() and CCMenuItemImage::unselected() does nothing.