AniPickLevelScene.cpp
2.59 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
67
68
69
70
71
72
73
74
75
76
//
// AniPickLevelScene.cpp
// SteveMaggieCpp
//
// Created by Katarzyna Kalinowska-Górska on 16.05.2017.
//
//
#include "AniPickLevelScene.h"
#include "AniPlainLabel.h"
#include "AniSoundsRepo.h"
AniPickLevelScene* AniPickLevelScene::create(std::string layoutFilePath)
{
AniPickLevelScene* scene = new (std::nothrow) AniPickLevelScene();
if(scene && scene->init(layoutFilePath))
{
scene->autorelease();
return scene;
}
CC_SAFE_DELETE(scene);
return nullptr;
}
bool AniPickLevelScene::init(std::string layoutFilePath){
if(!AniParentScene::initWithConfigurationFiles(layoutFilePath)){
return false;
}
return true;
}
void AniPickLevelScene::onEnter(){
AniParentScene::onEnter();
showTOSAcceptPopup([&](){
isShowingLevelPicker = true;
showAniLevelPickerLayer([&]{
stopAllActions();
AniSoundsRepo::preloadAllTutorialGameSounds();
AniSoundsRepo::preloadAllLoadedSoundEffects();
gameStaticCreator.preloadGameResources([&](std::vector<std::string>){
cocos2d::Director::getInstance()->replaceScene(gameStaticCreator.createGameScene());
});
}, [&](int level){
//TODO handle level change if necessary
});
auto pickLevelSoundInfo = AniSoundsRepo::pickLevelSound();
runAction(cocos2d::Sequence::create(cocos2d::CallFunc::create(std::bind([&](std::string pickLevelSoundPath){
AniSoundsRepo::playSound(pickLevelSoundPath);
repeatPickLevelPrompt();
},pickLevelSoundInfo.filePath)),
nullptr));
});
}
//bool AniPickLevelScene::touchHandlerForWidget(std::string objectName, cocos2d::ui::Widget::TouchEventType touchEventType)
//{
// /*if(objectName == "settingsButton" && touchEventType == cocos2d::ui::Widget::TouchEventType::ENDED){
// if(!gameState->settingsMenuShown){
// showSettingsMenu();
// } else {
// if(settingsMenu->isShowingParentalGate()){
// settingsMenu->hideParentalGate();
// } else {
// settingsMenu->hideParentalGate(); // in case showing parental gate is in progress...
// hideSettingsMenu();
// replayGame();
// }
// }
// } else*/ if(objectName == "replayButton" && touchEventType == cocos2d::ui::Widget::TouchEventType::ENDED){
// replayGame();
// return true;
// }
//
// return false;
//}