After weeks of debugging, I struggle to figure out what was going on with cocos2d::Menu. I was surprise that my MenuItemImage was not receiving callbacks when I click on the button. So I click anywhere else out of frustration and boom, as I clicked on the bottom left corner, the callback registers in!
Its a bit off towards the bottom-left and wondering what might caused this? I already reproduce the problem using the crappy sample project provided as is and was not able to reproduce this using the default window size. But the problem was now reproducible when I change to a custom size. I also notice that the detection bounds seems to be not the actual shape of the given MenuItemImage. Its a bit square.
I am quite on predicament here. This is really frustrating. Documentation and the community is as unhelpful as hell.
I am using cocos2d-x v3.6;
Here is my code:
mRetryButton = cocos2d::MenuItemImage::create("asset_button_up.png", "asset_button_down.png", CC_CALLBACK_1(MainGameScene::onRetryButtonClicked, this));
mRetryButton->setPosition(cocos2d::Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f));
auto menu = cocos2d::Menu::create(mRetryButton, NULL);
menu->setPosition(cocos2d::Vec2::ZERO);
this->addChild(menu, 1);
Do you know any solution to this? Or did I just horribly missed something? I just needed a simple on-screen button. Nothing fancy. Just plain-old dull button.
Thanks!