The manager is the only object that creates, switches, and updates Scenes.
More...
#include <Imago/Engine/SceneManager.hpp>
|
|
using | SceneFactoryFn = std::unique_ptr<Scene>(*)(const SceneContext&) |
| | A function pointer to a function that builds one specific Scene type. One is instantiated per registered type.
|
|
| | SceneManager (const SceneContext &gameCtx) |
| | Construct a new SceneManager object, instantiating gameCtx so it can be copied into every Scene it builds.
|
|
| ~SceneManager () |
| | Unloads the active scene then destroys every live scene in _scenes.
|
|
| SceneManager (const SceneManager &)=delete |
|
SceneManager & | operator= (const SceneManager &)=delete |
|
| SceneManager (SceneManager &&)=delete |
|
SceneManager & | operator= (SceneManager &&)=delete |
| template<typename T> |
| void | register_scene (const std::string &name) |
| | Registers a Scene type under a name. The scene is not build on registration but instead a factory to a method that builds the Scene is stored and then called when that Scene is switched to for the first time.
|
| void | request_switch (const std::string &name, bool persist) |
| | Records a request to switch scenes. The switch is not actually applied until the end of the frame. If several switch requests occur during the same frame, the last one wins.
|
| bool | apply_pending_switch () |
| | Actually switch the pending Scene. Called by Game at the end of each frame.
|
| void | update (float dt) |
| | Updates the active scene. Does nothing if there is no active Scene.
|
The manager is the only object that creates, switches, and updates Scenes.
Scenes are registered by name with register_scene and built on first use. Only one Scene can be active at a time. Switching is defferred to the end of the current frame.
◆ SceneManager()
| Imago::Engine::SceneManager::SceneManager |
( |
const SceneContext & | gameCtx | ) |
|
|
explicit |
Construct a new SceneManager object, instantiating gameCtx so it can be copied into every Scene it builds.
- Parameters
-
◆ apply_pending_switch()
| bool Imago::Engine::SceneManager::apply_pending_switch |
( |
| ) |
|
Actually switch the pending Scene. Called by Game at the end of each frame.
- Returns
- true if there was a pending switch that was applied
◆ register_scene()
template<typename T>
| void Imago::Engine::SceneManager::register_scene |
( |
const std::string & | name | ) |
|
Registers a Scene type under a name. The scene is not build on registration but instead a factory to a method that builds the Scene is stored and then called when that Scene is switched to for the first time.
- Template Parameters
-
| T | Type of Scene to register. |
- Parameters
-
◆ request_switch()
| void Imago::Engine::SceneManager::request_switch |
( |
const std::string & | name, |
|
|
bool | persist ) |
Records a request to switch scenes. The switch is not actually applied until the end of the frame. If several switch requests occur during the same frame, the last one wins.
- Parameters
-
| name | The name of the registered scene to switch to. |
| persist | Whether or not the scene should be suspended (true) or completely destroyed (false). |
◆ update()
| void Imago::Engine::SceneManager::update |
( |
float | dt | ) |
|
Updates the active scene. Does nothing if there is no active Scene.
- Parameters
-
| dt | Real time since the last frame in seconds. |
The documentation for this class was generated from the following files: