// // ToyMainMenuScene.h // WattsenglishToyApp // // Created by Katarzyna Kalinowska-Górska on 16/11/2019. // #ifndef ToyMainMenuScene_h #define ToyMainMenuScene_h #include "ToyMiscUtils.h" #include "cocos2d.h" #include "ToyParentScene.h" #include "ToySettingsLayer.h" #include "ToyParentalGateShowInterface.h" class ToyMainMenuScene : public ToyParentScene, public ToyParentalGateShowInterface { public: static ToyMainMenuScene* create(std::string layoutFilePath = ""); virtual bool initWithConfigurationFiles(std::string layoutFilePath = ""); virtual void onEnter() override; virtual void onExit() override; protected: ToySettingsLayer* settingsMenu; bool isShowingSettings; bool firstEnter; virtual void playMusicIfRequired(); virtual void setupButtons(); virtual void prepareSettingsMenu(); virtual void prepareBgMusicButton(); virtual void moveSettingsButtonToFront(int localZOrder); virtual void showSettingsMenu(bool animated = true); virtual void hideSettingsMenu(bool animated = true); void settingsButtonTapped(cocos2d::Ref* pSender); void game1Tapped(cocos2d::Ref* pSender); void game2Tapped(cocos2d::Ref* pSender); void worksheet1Tapped(cocos2d::Ref* pSender); void worksheet2Tapped(cocos2d::Ref* pSender); void exitTapped(cocos2d::Ref* pSender); void showTOSAcceptPopup(std::function onAccept) override; #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) cocos2d::EventListenerKeyboard* _keyboardListener; void addBackButtonListener(){ _keyboardListener = cocos2d::EventListenerKeyboard::create(); _keyboardListener->onKeyReleased = [&](cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event* event){ if(keyCode == cocos2d::EventKeyboard::KeyCode::KEY_BACK){ // if(!gameState->settingsMenuShown && !gameState->tosAcceptMenuShown){ ToyMiscUtils::showAppCloseConfirmDialog([&](){ }); // } } }; cocos2d::Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(_keyboardListener, this); } #endif }; #endif /* ToyMainMenuScene_h */