-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSceneManager.cpp
76 lines (63 loc) · 1.84 KB
/
SceneManager.cpp
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
#include "SceneManager.h"
#include "HelloWorldScene.h"
#include "SplashScreen.h"
#include "Menu.h"
// #include "Menu.h"
// #include "LevelSelector.h"
// #include "ScoreScreen.h"
// #include "Store.h"
// #include "Level2.h"
USING_NS_CC;
float SceneManager::setScreenX, SceneManager::setScreenY;
CCScene* SceneManager::scene(){
CCScene * scene = NULL;
do
{ // 'scene' is an autorelease object
scene = CCScene::create();
CC_BREAK_IF(! scene);
// 'layer' is an autorelease object
SceneManager *layer = SceneManager::create();
CC_BREAK_IF(! layer);
// add layer as a child to scene
scene->addChild(layer);
} while (0);
// return the scene
return scene;
}
CCSprite* SceneManager::func_createImage(char const* name, int anchorx, int anchory, int posx, int posy) {
CCSprite* temp = CCSprite::create(name);
temp->setAnchorPoint(ccp(anchorx, anchory));
temp->setPositionX(posx*setScreenX);
temp->setPositionY(posy*setScreenY);
temp->setScaleX(setScreenX);
temp->setScaleY(setScreenY);
return temp;
}
SceneManager::SceneManager(void)
{
}
SceneManager::~SceneManager(void)
{
}
bool SceneManager::init(){
if (!CCLayer::init()) {
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
setScreenX = size.width/800;
setScreenY = size.height/480;
CCFiniteTimeAction *seq1 = CCSequence::create(CCDelayTime::create(0.1),
CCCallFuncN::create(this,
callfuncN_selector(SceneManager::StartSplashScene)), NULL);
this->runAction(seq1);
return true;
}
void SceneManager::StartSplashScene(CCNode* sender){
CCDirector::sharedDirector()->replaceScene(SplashScreen::scene());
}
void SceneManager::StartMenuScene(CCNode* sender) {
CCDirector::sharedDirector()->replaceScene(Menu::scene());
}
void StartLevelSelector(CCNode* sender) {
// CCDirector:.sharedDirector()->replaceScene(LevelSelector::scene());
}