ToyMainMenuScene.h
2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// 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<void()> 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 */