-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path03-scene-manager-with-two-scenes.inl
52 lines (49 loc) · 1.58 KB
/
03-scene-manager-with-two-scenes.inl
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
#define SCENE_TITLE 1
#define SCENE_GAME 2
ZL_Font fnt;
struct sSceneGame : public ZL_Scene
{
sSceneGame() : ZL_Scene(SCENE_GAME) { }
int InitTransitionEnter(ZL_SceneType SceneTypeFrom, void* data) { return 500; }
int DeInitTransitionLeave(ZL_SceneType SceneTypeTo) { return 500; }
void Draw()
{
ZL_Display::ClearFill(ZL_Color::Blue);
fnt.Draw(ZLHALFW, ZLHALFH, "THIS IS THE GAME SCENE", ZL_Origin::Center);
}
void DrawTransition(scalar f, bool IsLeaveTransition)
{
Draw();
ZL_Display::FillRect(0, 0, ZLWIDTH, ZLHEIGHT, ZLRGBA(0, 0, 0, f));
}
} sSceneGame;
struct sSceneTitle : public ZL_Scene
{
sSceneTitle() : ZL_Scene(SCENE_TITLE) { }
int InitTransitionEnter(ZL_SceneType SceneTypeFrom, void* data) { return 500; }
int DeInitTransitionLeave(ZL_SceneType SceneTypeTo) { return 500; }
void Draw()
{
ZL_Display::ClearFill(ZL_Color::Cyan);
fnt.Draw(ZLHALFW, ZLHALFH, "TITLE SCENE", ZL_Color::Black, ZL_Origin::Center);
}
void DrawTransition(scalar f, bool IsLeaveTransition)
{
Draw();
ZL_Display::FillRect(0, 0, ZLWIDTH, ZLHEIGHT, ZLRGBA(0, 0, 0, f));
}
} sSceneTitle;
struct sMain : public ZL_Application
{
void Load(int argc, char *argv[])
{
ZL_Display::Init("Scene Manager With Two Scenes", 854, 480);
fnt = ZL_Font("Data/fntMain.png");
ZL_SceneManager::Init(SCENE_TITLE);
ZL_Display::sigPointerDown.connect(this, &sMain::OnPointerDown);
}
void OnPointerDown(ZL_PointerPressEvent& e)
{
ZL_SceneManager::GoToScene(ZL_SceneManager::GetCurrent()->SceneType == SCENE_TITLE ? SCENE_GAME : SCENE_TITLE);
}
} Main;