commands/scene_stack_commands¶
Goal¶
Understand the built-in scene-stack commands — Push, Pop, and Change — and see them navigate between three scenes.
Why this tutorial exists¶
Scene navigation is driven entirely by commands. The engine provides:
PushSceneCommand — pushes a new scene onto the stack (previous scene stays underneath)
PopSceneCommand — pops the top scene, returning to the one below
ChangeSceneCommand — replaces the current scene entirely
This example wires three scenes and lets you trigger each command type with keyboard shortcuts.
Source map¶
Settings profile:
examples/settings/commands/scene_stack_commands.ymlExample builder:
examples/catalog/commands/scene_stack_commands/main.pyScene:
examples/catalog/commands/scene_stack_commands/scenes/scene.pyShared runner:
examples/_shared/runner.py
What to verify¶
You should see:
Main scene (blue) — press
Oto push an overlay,Cto change to an alternate sceneOverlay scene (green, semi-transparent) — press
Backspaceto pop back to the main sceneAlternate scene (red) — press
Backspaceto change back to main
Behavior checks:
pushing the overlay does not destroy the main scene underneath
popping returns to the exact state the main scene was in
changing to the alternate scene removes the main scene from the stack
the stack depth indicator updates correctly
Controls¶
Key |
Action |
|---|---|
|
Push overlay |
|
Change to alternate |
|
Pop / go back |
|
Quit |
Run¶
mini-arcade run --example commands/scene_stack_commands
mini-arcade run --example commands/scene_stack_commands --pass-through --backend pygame
mini-arcade run --example commands/scene_stack_commands --pass-through --backend native
Common mistakes¶
Popping when only one scene is on the stack — causes the engine to quit or error.
Using Change when you mean Push — the previous scene is lost.
Registering scenes in a separate package that isn’t in
discover_packages.