Add Music fluctuations project and Chinese plan docs
This commit is contained in:
37
MVS/Music fluctuations/source/scene/SceneManager.cpp
Normal file
37
MVS/Music fluctuations/source/scene/SceneManager.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include"SceneManager.h"
|
||||
#include"Scene.h"
|
||||
|
||||
SceneManager::SceneManager(){}
|
||||
|
||||
SceneManager::~SceneManager(){}
|
||||
|
||||
void SceneManager::ChangeScene(Scene* p_nextScene)
|
||||
{
|
||||
if (p_nextScene == nullptr) { return; }
|
||||
if (m_currentScene != nullptr)
|
||||
{
|
||||
p_nextScene->m_context = m_currentScene->m_context;
|
||||
m_currentScene->OnExit();
|
||||
}
|
||||
p_nextScene->OnEnter();
|
||||
m_currentScene = p_nextScene;
|
||||
}
|
||||
|
||||
void SceneManager::ChangeScene(std::string p_name)
|
||||
{
|
||||
if (Scene* scene = GetScene(p_name); scene)
|
||||
ChangeScene(scene);
|
||||
}
|
||||
|
||||
void SceneManager::RegisterScene(std::string p_name, Scene* p_scene)
|
||||
{
|
||||
if (m_scenes.find(p_name) == m_scenes.end())
|
||||
m_scenes[p_name] = p_scene;
|
||||
}
|
||||
|
||||
Scene* SceneManager::GetScene(std::string p_name)
|
||||
{
|
||||
if (m_scenes.find(p_name) != m_scenes.end())
|
||||
return m_scenes[p_name];
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user