Hello,
I just migrated to version 2.2.2 (coming from version 2.2.1) and the code that I was using for loading a scene and binding callback methods to buttons isn’t working any more.
CCNode *pGameScene = SceneReader::sharedSceneReader()->createNodeWithSceneFile("MyMenu.json");
this->addChild(pGameScene);
UILayer* layer = dynamic_cast<UILayer*>(((CCNode*)pGameScene->getChildByTag(10003))->getComponent("GUIComponent")->getNode());
if (layer == NULL)
{
break;
}
UIButton* myButton= static_cast<UIButton*>(layer->getWidgetByName("main_panel")->getChildByName("myButton"));
if (myButton == NULL)
{
break;
}
myButton->addTouchEventListener(this, (SEL_TouchEvent)&MenuLayer::myButtonCallback);
The first problem is that the namespcae changed, I fixed this by adding the namespace cocos2d::gui. The 2nd problem is that the method getNode() does no longer exist in CCComponent.
So my question is, what is the new way for getting my button and adding a TouchEventListener.
Cheers
Tom