the scene that updates, or null when the stack is empty
Destroys the top scene and resumes the one below with result.
Throws when only one scene is left: popping it would leave the game with nothing to run, which is always an authoring error rather than intent.
Optionalresult: unknownevery scene relayouts, including the suspended ones waiting underneath
only the top scene runs; the suspended ones wait underneath
The stack of scenes a
Gameruns: exactly one updates, all render.Generic over the scene type, and typed against
core.Scene's lifecycle rather than any display node, so a Pixi game usesSceneStack<Scene2D>and a Babylon game its own - this class only ever callscreate,destroy,resize,update,onSuspendandonResume.switchScenereplaces the whole stack, for moving between screens.pushScenesuspends the current scene and starts another on top of it - a minigame over the dungeon, a pause menu over play - andpopScenedestroys the top and resumes whatever was underneath, reporting back a result. Only the top scene updates; every scene in the stack stays in the display list, so a pushed scene can be translucent (layered over) or opaque (instead of).Takes instances, never classes: constructing scenes is the
Game's job, and keeping it out is what keeps this testable without a browser.Example