-
warning717Likes 1
This worked for me:
I wasnt able to change the scene directly so I just used a scheduler. Hopefully this will be of some use to others.
In CPP
cocos2d::ui::Button *button = ( cocos2d::ui::Button * )rootNode->getChildByTag( 8 ); button->addTouchEventListener([&](Ref* sender, Widget::TouchEventType type){ switch (type) { case ui::Widget::TouchEventType::BEGAN: break; case ui::Widget::TouchEventType::ENDED: //std::cout << "Button 1 clicked" << std::endl; //Change Scene this->schedule(schedule_selector(MainMenu::ChangeScene), 1.0f); break; default: break; } }); return true; } void MainMenu::ChangeScene(float dt) { // run main menu Scene *scene = HelloWorld::createScene( ); Director::getInstance( )->replaceScene( TransitionSlideInR::create( 1.0, scene ) ); }
In Header
private: void ChangeScene(float dt);
-
Sonar Systems adminLikes 0
You my good friend are amazing. We forgot all about putting it on there. We will update the Cocos API Guide tomorrow.
That is the way of doing it BTW.
-
warning717Likes 1
Haha okay and thank you very much for the API Guide. I find it very helpful :D
-
Sonar Systems adminLikes 0
Updated the button section on the API Guide accordingly.
Thank you very much for letting us know
Login to reply