Engine
Raylib based game framework
Loading...
Searching...
No Matches
SceneManager Class Reference

Manages scenes and the execution of the current active scene. More...

#include <SceneManager.hpp>

Public Member Functions

template<typename SceneT, typename... Args>
void AddScene (Args &&... args)
 Adds a scene to the manager.
template<typename SceneT>
void RemoveScene ()
 Removes a scene from the manager.
template<typename SceneT>
void ChangeScene ()
 Queues a scene transition to be applied at the end of the current frame.
void ClearScenes ()
 Removes all scenes and clears the active scene pointer.

Friends

class Engine

Detailed Description

Manages scenes and the execution of the current active scene.

Only one scene can be active at a time. Scene transitions are queued and applied at the end of the current Draw call so that OnExit and OnEnter are never called mid-update.

Scenes update and draw after systems each frame.

Member Function Documentation

◆ AddScene()

template<typename SceneT, typename... Args>
void SceneManager::AddScene ( Args &&... args)
inline

Adds a scene to the manager.

The scene is constructed within the manager and owned by it. Scenes must derive from the Scene base class.

Template Parameters
SceneTScene type
ArgsConstructor argument types
Parameters
argsSceneT constructor arguments

Usage:

sceneManager.AddScene<MenuScene>("Menu", menuTitle);

◆ ChangeScene()

template<typename SceneT>
void SceneManager::ChangeScene ( )
inline

Queues a scene transition to be applied at the end of the current frame.

OnExit of the current scene is called followed by OnEnter of the next scene. The transition happens inside CheckForChange at the end of Draw. Asserts if the target scene does not exist or is already the active scene.

Template Parameters
SceneTType of the scene to transition to

◆ ClearScenes()

void SceneManager::ClearScenes ( )

Removes all scenes and clears the active scene pointer.

Called by the Engine destructor.

◆ RemoveScene()

template<typename SceneT>
void SceneManager::RemoveScene ( )
inline

Removes a scene from the manager.

Asserts if the scene to remove is the currently active scene.

Template Parameters
SceneTScene type to remove

The documentation for this class was generated from the following files: