menu_selector from Cocos2d-x 2.1.4 to 3.0Alpha0?

in Cocos2d-x 2.1.4 I could do:

cocos2d::CCMenuItemImage* pItem = cocos2d::CCMenuItemImage::create("button.png", "button.png", this,
                                                                               menu_selector(HUDForStatus::harvestAsparagus));

I dont know how to handle the menu_selector in 3.0Alpha0.

Can anyone tell me what to do? in 3.0 we can pass parameters too, correct?

New call would be…

MenuItemImage* pItem = MenuItemImage::create(“button.png”, “button.png”, CC_CALLBACK_1(HUDForStatus::harvestAsparagus, this));

See the release notes with the downloads as what helped me work all this lot out…

Peter, I get a no matching function call, but looking at CCMenuItem.h it does have:

/** creates a menu item with a normal and selected image with a callable object */
    static MenuItemImage* create(const char *normalImage, const char *selectedImage, const ccMenuCallback& callback);

Have you ensured that “HUDForStatus::harvestAsparagus” has the correct arguments?

it must be:

 void HUDForStatus::harvestAsparagus(Object* sender){ ... }

for been used like :

MenuItemImage* pItem = MenuItemImage::create("button.png", "button.png", CC_CALLBACK_1(HUDForStatus::harvestAsparagus, this));

Hope this help :wink:

I got it working actually. I decided to use Lambda’s. Thanks for replying.

Lambda is ok.
by the way, try CC_CALLBACK_0(HUDForStatus::harvestAsparagus, this);
however it work well on me. Just pay attaintion to parameter numbers.