The Scene Manager.
The Scene Manager is a Game level system, responsible for creating, processing and updating all of the Scenes in a Game instance.
You should not usually interact directly with the Scene Manager at all. Instead, you should use
the Scene Plugin, which is available from every Scene in your game via the this.scene
property.
Using methods in this Scene Manager directly will break queued operations and can cause runtime errors. Instead, go via the Scene Plugin. Every feature this Scene Manager provides is also available via the Scene Plugin.
new SceneManager(game, sceneConfig)
name | type | description |
---|---|---|
game | Phaser.Game |
The Phaser.Game instance this Scene Manager belongs to. |
sceneConfig | object |
Scene specific configuration settings. |
Do any of the Cameras in any of the Scenes require a custom viewport? If not we can skip scissor tests.
Has the Scene Manager properly started?
Is the Scene Manager actively processing the Scenes list?
An object that maps the keys to the scene so we can quickly get a scene from a key without iteration.
The array in which all of the scenes are kept.
This system Scene is created during bootQueue
and is a default
empty Scene that lives outside of the Scene list, but can be used
by plugins and managers that need access to a live Scene, without
being tied to one.
Adds a new Scene into the SceneManager. You must give each Scene a unique key by which you'll identify it.
The sceneConfig
can be:
Phaser.Scene
object, or an object that extends it.Phaser.Scene
If a function is given then a new Scene will be created by calling it.
name | type | arguments | Default | description |
---|---|---|---|---|
key | string |
A unique key used to reference the Scene, i.e. |
||
sceneConfig | Phaser.Types.Scenes.SceneType |
The config for the Scene |
||
autoStart | boolean | <optional> | false |
If |
data | object | <optional> |
Optional data object. This will be set as |
The added Scene, if it was added immediately, otherwise null
.
Brings a Scene to the top of the Scenes list.
This means it will render above all other Scenes.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The Scene to move. |
This Scene Manager instance.
Destroy this Scene Manager and all of its systems.
This process cannot be reversed.
This method is called automatically when a Phaser Game instance is destroyed.
Dumps debug information about each Scene to the developer console.
Retrieves a Scene by numeric index.
name | type | description |
---|---|---|
index | number |
The index of the Scene to retrieve. |
The Scene.
Retrieves the numeric index of a Scene.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The key of the Scene. |
The index of the Scene.
Retrieves a Scene based on the given key.
If an actual Scene is passed to this method, it can be used to check if its currently within the Scene Manager, or not.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The key of the Scene to retrieve. |
The Scene, or null
if no matching Scene was found.
Returns an array of all the current Scenes being managed by this Scene Manager.
You can filter the output by the active state of the Scene and choose to have the array returned in normal or reversed order.
name | type | arguments | Default | description |
---|---|---|---|---|
isActive | boolean | <optional> | true |
Only include Scene's that are currently active? |
inReverse | boolean | <optional> | false |
Return the array of Scenes in reverse? |
An array containing all of the Scenes in the Scene Manager.
Determines whether a Scene is running.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The Scene to check. |
Whether the Scene is running, or null
if no matching Scene was found.
Determines whether a Scene is paused.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The Scene to check. |
Whether the Scene is paused, or null
if no matching Scene was found.
Determines whether a Scene is sleeping.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The Scene to check. |
Whether the Scene is sleeping, or null
if no matching Scene was found.
Determines whether a Scene is visible.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The Scene to check. |
Whether the Scene is visible, or null
if no matching Scene was found.
Moves a Scene so it is immediately above another Scene in the Scenes list. If the Scene is already above the other, it isn't moved.
This means it will render over the top of the other Scene.
name | type | description |
---|---|---|
keyA | string | Phaser.Scene |
The Scene that Scene B will be moved above. |
keyB | string | Phaser.Scene |
The Scene to be moved. |
This Scene Manager instance.
Moves a Scene so it is immediately below another Scene in the Scenes list. If the Scene is already below the other, it isn't moved.
This means it will render behind the other Scene.
name | type | description |
---|---|---|
keyA | string | Phaser.Scene |
The Scene that Scene B will be moved below. |
keyB | string | Phaser.Scene |
The Scene to be moved. |
This Scene Manager instance.
Moves a Scene down one position in the Scenes list.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The Scene to move. |
This Scene Manager instance.
Moves a Scene up one position in the Scenes list.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The Scene to move. |
This Scene Manager instance.
Pauses the given Scene.
name | type | arguments | description |
---|---|---|---|
key | string | Phaser.Scene |
The Scene to pause. |
|
data | object | <optional> |
An optional data object that will be passed to the Scene and emitted by its pause event. |
This Scene Manager instance.
Process the Scene operations queue.
Removes a Scene from the SceneManager.
The Scene is removed from the local scenes array, it's key is cleared from the keys cache and Scene.Systems.destroy is then called on it.
If the SceneManager is processing the Scenes when this method is called it will queue the operation for the next update sequence.
name | type | description |
---|---|---|
key | string |
A unique key used to reference the Scene, i.e. |
This Scene Manager instance.
Renders the Scenes.
name | type | description |
---|---|---|
renderer | Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer |
The renderer to use. |
Resumes the given Scene.
name | type | arguments | description |
---|---|---|---|
key | string | Phaser.Scene |
The Scene to resume. |
|
data | object | <optional> |
An optional data object that will be passed to the Scene and emitted by its resume event. |
This Scene Manager instance.
Runs the given Scene.
If the given Scene is paused, it will resume it. If sleeping, it will wake it. If not running at all, it will be started.
Use this if you wish to open a modal Scene by calling pause
on the current
Scene, then run
on the modal Scene.
name | type | arguments | description |
---|---|---|---|
key | string | Phaser.Scene |
The Scene to run. |
|
data | object | <optional> |
A data object that will be passed to the Scene on start, wake, or resume. |
This Scene Manager instance.
Sends a Scene to the back of the Scenes list.
This means it will render below all other Scenes.
name | type | description |
---|---|---|
key | string | Phaser.Scene |
The Scene to move. |
This Scene Manager instance.
Puts the given Scene to sleep.
name | type | arguments | description |
---|---|---|---|
key | string | Phaser.Scene |
The Scene to put to sleep. |
|
data | object | <optional> |
An optional data object that will be passed to the Scene and emitted by its sleep event. |
This Scene Manager instance.
Starts the given Scene, if it is not starting, loading, or creating.
If the Scene is running, paused, or sleeping, it will be shutdown and then started.
name | type | arguments | description |
---|---|---|---|
key | string | Phaser.Scene |
The Scene to start. |
|
data | object | <optional> |
Optional data object to pass to |
This Scene Manager instance.
Stops the given Scene.
name | type | arguments | description |
---|---|---|---|
key | string | Phaser.Scene |
The Scene to stop. |
|
data | object | <optional> |
Optional data object to pass to Scene.shutdown. |
This Scene Manager instance.
Swaps the positions of two Scenes in the Scenes list.
name | type | description |
---|---|---|
keyA | string | Phaser.Scene |
The first Scene to swap. |
keyB | string | Phaser.Scene |
The second Scene to swap. |
This Scene Manager instance.
Sleeps one one Scene and starts the other.
name | type | arguments | description |
---|---|---|---|
from | string | Phaser.Scene |
The Scene to sleep. |
|
to | string | Phaser.Scene |
The Scene to start. |
|
data | object | <optional> |
Optional data object to pass to |
This Scene Manager instance.
Updates the Scenes.
name | type | description |
---|---|---|
time | number |
Time elapsed. |
delta | number |
Delta time from the last update. |
Awakens the given Scene.
name | type | arguments | description |
---|---|---|---|
key | string | Phaser.Scene |
The Scene to wake up. |
|
data | object | <optional> |
An optional data object that will be passed to the Scene and emitted by its wake event. |
This Scene Manager instance.