Trait that adds scene transition lifecycle hooks to any class. More...
#include <Malena/Engine/Scenes/SceneLifecycle.h>
Public Member Functions | |
| virtual | ~SceneLifecycle ()=default |
| virtual void | onSceneEnter () |
| Called every time this scene becomes the active scene. | |
| virtual void | onSceneExit () |
| Called every time this scene is deactivated. | |
| virtual void | onScenePause () |
| Called when this scene is pushed to the background by another scene. | |
| virtual void | onSceneResume () |
| Called when this scene is returned to the foreground. | |
Trait that adds scene transition lifecycle hooks to any class.
SceneLifecycle provides four virtual hooks that fire on scene transitions managed by SceneManager. All have empty default implementations — override only what you need.
| Hook | When it fires |
|---|---|
onSceneEnter() | Every time this scene becomes the active scene |
onSceneExit() | Every time this scene is deactivated |
onScenePause() | This scene is pushed to the background by another |
onSceneResume() | This scene is returned to the foreground |
The key distinction from Lifecycle is that these hooks fire on every transition, not just once at startup. A cached scene that is entered, exited, and re-entered will have onSceneEnter() called twice but Lifecycle::onInit() called only once.
Combine with Lifecycle when the scene also needs one-time initialization hooks:
Definition at line 87 of file SceneLifecycle.h.
|
virtualdefault |
|
inlinevirtual |
Called every time this scene becomes the active scene.
Override to resume audio, reset timers, trigger entry animations, or perform any setup that should repeat on each activation.
Definition at line 96 of file SceneLifecycle.h.
|
inlinevirtual |
Called every time this scene is deactivated.
Override to pause audio, persist state, or clean up resources that should not run while the scene is inactive.
Definition at line 104 of file SceneLifecycle.h.
|
inlinevirtual |
Called when this scene is pushed to the background by another scene.
The scene remains alive and cached but is no longer the active scene. Override to freeze simulation, suppress input handling, or dim visuals.
Definition at line 112 of file SceneLifecycle.h.
|
inlinevirtual |
Called when this scene is returned to the foreground.
Paired with onScenePause(). Override to restore state that was suppressed when the scene was backgrounded.
Definition at line 120 of file SceneLifecycle.h.