Base class representing a game scene that manages actors and rendering. Scenes handle actor lifecycles (add, update, remove) and are tied to a specific window and renderer. Derived classes should override Load and Start to define behavior.
More...
#include <Scene.h>
|
| Scene () |
|
virtual | ~Scene () |
| Scene destructor. Cleans up all actors and clears loaded assets.
|
|
virtual void | Load () |
| Called once before the scene starts. Override to load assets or initialize data.
|
|
virtual void | Start ()=0 |
| Called once after Load. Must be implemented to initialize gameplay logic.
|
|
virtual void | Update (float deltaTime) |
| Updates all actors in the scene. Handles actor lifecycle: updates active ones, removes dead ones, and adds any newly pending actors.
|
|
void | SetWindow (Window *pWindow) |
| Sets the window associated with the scene.
|
|
Window * | GetWindow () |
| Gets the window in which the scene in showing.
|
|
void | SetRenderer (IRenderer *pRenderer) |
| Sets the renderer used by the scene.
|
|
IRenderer * | GetRenderer () |
| Gets the renderer associated with the scene.
|
|
void | Reload () |
| Reloads the scene. This is safe to call during an update since the operation happens at the end of an update.
|
|
void | AddActor (Actor *pActor) |
| Adds a new actor to the scene. If called during actor updates, the addition is deferred until the update cycle ends.
|
|
void | RemoveActor (Actor *pActor) |
| Removes an actor from the scene, either from the active or pending actor lists.
|
|
Base class representing a game scene that manages actors and rendering. Scenes handle actor lifecycles (add, update, remove) and are tied to a specific window and renderer. Derived classes should override Load and Start to define behavior.
◆ Scene()
◆ ~Scene()
Scene destructor. Cleans up all actors and clears loaded assets.
◆ AddActor()
void Scene::AddActor |
( |
Actor * | pActor | ) |
|
Adds a new actor to the scene. If called during actor updates, the addition is deferred until the update cycle ends.
- Parameters
-
pActor | Pointer to the actor to add. |
◆ GetRenderer()
Gets the renderer associated with the scene.
- Returns
- Pointer to the IRenderer instance used by the scene.
◆ GetWindow()
Gets the window in which the scene in showing.
- Returns
- Pointer to the Window instance used by the scene.
◆ Load()
virtual void Scene::Load |
( |
| ) |
|
|
inlinevirtual |
Called once before the scene starts. Override to load assets or initialize data.
◆ Reload()
Reloads the scene. This is safe to call during an update since the operation happens at the end of an update.
◆ RemoveActor()
void Scene::RemoveActor |
( |
Actor * | pActor | ) |
|
Removes an actor from the scene, either from the active or pending actor lists.
- Parameters
-
pActor | Pointer to the actor to be removed. |
The function searches for the actor in both mPendingActors
and mActors
, swaps it with the last element if found, and then removes it from the list. This avoids invalidating iterators and ensures efficient removal.
◆ SetRenderer()
void Scene::SetRenderer |
( |
IRenderer * | pRenderer | ) |
|
Sets the renderer used by the scene.
- Parameters
-
pRenderer | Pointer to the IRenderer implementation. |
◆ SetWindow()
void Scene::SetWindow |
( |
Window * | pWindow | ) |
|
Sets the window associated with the scene.
- Parameters
-
pWindow | Pointer to the Window instance. |
◆ Start()
virtual void Scene::Start |
( |
| ) |
|
|
pure virtual |
Called once after Load. Must be implemented to initialize gameplay logic.
◆ Update()
void Scene::Update |
( |
float | deltaTime | ) |
|
|
virtual |
Updates all actors in the scene. Handles actor lifecycle: updates active ones, removes dead ones, and adds any newly pending actors.
- Parameters
-
deltaTime | Time elapsed since the last frame. |
◆ mActors
std::vector<Actor*> Scene::mActors {} |
|
protected |
List of currently active actors.
◆ mRenderer
Renderer responsible for drawing.
◆ mWindow
Pointer to the window the scene uses.
The documentation for this class was generated from the following files: