-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneManager.cpp
More file actions
54 lines (46 loc) · 1.08 KB
/
SceneManager.cpp
File metadata and controls
54 lines (46 loc) · 1.08 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
#include "SceneManager.h"
#include "WaitingScene.h"
#include <Windows.h>
#include "RunningScene.h"
#include "EndingScene.h"
SceneManager SceneManager::instance;
SceneManager::SceneManager() {
currentScene = new WaitingScene();
sceneList.push_back(currentScene);
sceneList.push_back(new RunningScene());
sceneList.push_back(new EndingScene());
}
SceneManager::~SceneManager() {
for (auto scene : sceneList) {
delete scene;
}
}
void SceneManager::ChangeScene(const std::string& name) {
bool result = false;
for (auto scene : sceneList) {
if (scene->GetName()._Equal(name)) {
currentScene = scene;
currentScene->Init();
result = true;
break;
}
}
if (!result) {
MessageBox(NULL, "シーンの切り替えに失敗しました。指定された名前のシーンが存在しません。", NULL, MB_OK | MB_ICONERROR);
}
}
void SceneManager::InitScene() {
if (currentScene != nullptr) {
currentScene->Init();
}
}
void SceneManager::UpdateScene() {
if (currentScene != nullptr) {
currentScene->Update();
}
}
void SceneManager::DrawScene() {
if (currentScene != nullptr) {
currentScene->Draw();
}
}