new ScenePlugin(scene)
Parameters:
| Name | Type | Description |
|---|---|---|
scene |
Phaser.Scene | The Scene that this ScenePlugin belongs to. |
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 13)
Members
-
key :string
-
The key of the Scene this ScenePlugin belongs to.
Type:
- string
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 57)
-
manager :Phaser.Scenes.SceneManager
-
The Game's SceneManager.
Type:
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 66)
-
scene :Phaser.Scene
-
The Scene that this ScenePlugin belongs to.
Type:
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 30)
-
settings :Phaser.Types.Scenes.SettingsObject
-
The settings of the Scene this ScenePlugin belongs to.
Type:
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 48)
-
systems :Phaser.Scenes.Systems
-
The Scene Systems instance of the Scene that this ScenePlugin belongs to.
Type:
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 39)
-
transitionProgress :number
-
If this Scene is currently transitioning to another, this holds the current percentage of the transition progress, between 0 and 1.
Type:
- number
- Since: 3.5.0
- Source: src/scene/ScenePlugin.js (Line 75)
Methods
-
add(key, sceneConfig, autoStart [, data])
-
Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set.
Parameters:
Name Type Argument Description keystring The Scene key.
sceneConfigPhaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | function The config for the Scene.
autoStartboolean Whether to start the Scene after it's added.
dataobject <optional>
Optional data object. This will be set as Scene.settings.data and passed to
Scene.init.- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 430)
Returns:
An instance of the Scene that was added to the Scene Manager.
- Type
- Phaser.Scene
-
bringToTop( [key])
-
Brings a Scene to the top of the Scenes list.
This means it will render above all other Scenes.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to move.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 889)
Returns:
This ScenePlugin object.
-
get(key)
-
Retrieve a Scene.
Parameters:
Name Type Description keystring The Scene to retrieve.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 931)
Returns:
The Scene.
- Type
- Phaser.Scene
-
getIndex( [key])
-
Retrieves the numeric index of a Scene in the Scenes list.
Parameters:
Name Type Argument Description keystring | Phaser.Scene <optional>
The Scene to get the index of.
- Since: 3.7.0
- Source: src/scene/ScenePlugin.js (Line 946)
Returns:
The index of the Scene.
- Type
- number
-
isActive( [key])
-
Checks if the given Scene is running or not?
Parameters:
Name Type Argument Description keystring <optional>
The Scene to check.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 700)
Returns:
Whether the Scene is running.
- Type
- boolean
-
isPaused( [key])
-
Checks if the given Scene is paused or not?
Parameters:
Name Type Argument Description keystring <optional>
The Scene to check.
- Since: 3.17.0
- Source: src/scene/ScenePlugin.js (Line 717)
Returns:
Whether the Scene is paused.
- Type
- boolean
-
isSleeping( [key])
-
Checks if the given Scene is sleeping or not?
Parameters:
Name Type Argument Description keystring <optional>
The Scene to check.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 683)
Returns:
Whether the Scene is sleeping.
- Type
- boolean
-
isVisible( [key])
-
Checks if the given Scene is visible or not?
Parameters:
Name Type Argument Description keystring <optional>
The Scene to check.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 734)
Returns:
Whether the Scene is visible.
- Type
- boolean
-
launch(key [, data])
-
Launch the given Scene and run it in parallel with this one.
This will happen at the next Scene Manager update, not immediately.
Parameters:
Name Type Argument Description keystring The Scene to launch.
dataobject <optional>
The Scene data.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 448)
Returns:
This ScenePlugin object.
-
moveAbove(keyA [, keyB])
-
Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A.
This controls the order in which they are rendered and updated.
Parameters:
Name Type Argument Description keyAstring The Scene that Scene B will be moved to be above.
keyBstring <optional>
The Scene to be moved. If none is given it defaults to this Scene.
- Since: 3.2.0
- Source: src/scene/ScenePlugin.js (Line 776)
Returns:
This ScenePlugin object.
-
moveBelow(keyA [, keyB])
-
Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A.
This controls the order in which they are rendered and updated.
Parameters:
Name Type Argument Description keyAstring The Scene that Scene B will be moved to be below.
keyBstring <optional>
The Scene to be moved. If none is given it defaults to this Scene.
- Since: 3.2.0
- Source: src/scene/ScenePlugin.js (Line 801)
Returns:
This ScenePlugin object.
-
moveDown( [key])
-
Moves a Scene down one position in the Scenes list.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to move.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 870)
Returns:
This ScenePlugin object.
-
moveUp( [key])
-
Moves a Scene up one position in the Scenes list.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to move.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 851)
Returns:
This ScenePlugin object.
-
pause( [key] [, data])
-
Pause the Scene - this stops the update step from happening but it still renders.
This will happen at the next Scene Manager update, not immediately.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to pause.
dataobject <optional>
An optional data object that will be passed to the Scene and emitted in its pause event.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 500)
Returns:
This ScenePlugin object.
-
remove( [key])
-
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.
Parameters:
Name Type Argument Description keystring | Phaser.Scene <optional>
The Scene to be removed.
- Since: 3.2.0
- Source: src/scene/ScenePlugin.js (Line 826)
Returns:
This SceneManager.
-
restart( [data])
-
Restarts this Scene.
This will happen at the next Scene Manager update, not immediately.
Parameters:
Name Type Argument Description dataobject <optional>
The Scene data.
- Since: 3.4.0
- Source: src/scene/ScenePlugin.js (Line 211)
Returns:
This ScenePlugin object.
-
resume( [key] [, data])
-
Resume the Scene - starts the update loop again.
This will happen at the next Scene Manager update, not immediately.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to resume.
dataobject <optional>
An optional data object that will be passed to the Scene and emitted in its resume event.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 522)
Returns:
This ScenePlugin object.
-
run(key [, data])
-
Runs the given Scene, but does not change the state of this Scene.
This will happen at the next Scene Manager update, not immediately.
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
pauseon the current Scene, thenrunon the modal Scene.Parameters:
Name Type Argument Description keystring The Scene to run.
dataobject <optional>
A data object that will be passed to the Scene and emitted in its ready, wake, or resume events.
- Since: 3.10.0
- Source: src/scene/ScenePlugin.js (Line 471)
Returns:
This ScenePlugin object.
-
sendToBack( [key])
-
Sends a Scene to the back of the Scenes list.
This means it will render below all other Scenes.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to move.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 910)
Returns:
This ScenePlugin object.
-
setActive(value [, key] [, data])
-
Sets the active state of the given Scene.
Parameters:
Name Type Argument Description valueboolean If
truethe Scene will be resumed. Iffalseit will be paused.keystring <optional>
The Scene to set the active state of.
dataobject <optional>
An optional data object that will be passed to the Scene and emitted with its events.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 632)
Returns:
This ScenePlugin object.
-
setVisible(value [, key])
-
Sets the visible state of the given Scene.
Parameters:
Name Type Argument Description valueboolean The visible value.
keystring <optional>
The Scene to set the visible state for.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 658)
Returns:
This ScenePlugin object.
-
sleep( [key] [, data])
-
Makes the Scene sleep (no update, no render) but doesn't shutdown.
This will happen at the next Scene Manager update, not immediately.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to put to sleep.
dataobject <optional>
An optional data object that will be passed to the Scene and emitted in its sleep event.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 544)
Returns:
This ScenePlugin object.
-
start( [key] [, data])
-
Shutdown this Scene and run the given one.
This will happen at the next Scene Manager update, not immediately.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to start.
dataobject <optional>
The Scene data.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 188)
Returns:
This ScenePlugin object.
-
stop( [key] [, data])
-
Shutdown the Scene, clearing display list, timers, etc.
This happens at the next Scene Manager update, not immediately.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to stop.
dataany <optional>
Optional data object to pass to Scene.Systems.shutdown.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 610)
Returns:
This ScenePlugin object.
-
swapPosition(keyA [, keyB])
-
Swaps the position of two scenes in the Scenes list.
This controls the order in which they are rendered and updated.
Parameters:
Name Type Argument Description keyAstring The first Scene to swap.
keyBstring <optional>
The second Scene to swap. If none is given it defaults to this Scene.
- Since: 3.2.0
- Source: src/scene/ScenePlugin.js (Line 751)
Returns:
This ScenePlugin object.
-
switch(key)
-
Makes this Scene sleep then starts the Scene given.
This will happen at the next Scene Manager update, not immediately.
Parameters:
Name Type Description keystring The Scene to start.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 588)
Returns:
This ScenePlugin object.
-
transition(config)
-
This will start a transition from the current Scene to the target Scene given.
The transition will last for the duration specified in milliseconds.
You can have the target Scene moved above or below this one in the display list.
You can specify an update callback. This callback will be invoked every frame for the duration of the transition.
This Scene can either be sent to sleep at the end of the transition, or stopped. The default is to stop.
There are also 5 transition related events: This scene will emit the event
transitionoutwhen the transition begins, which is typically the frame after calling this method.The target Scene will emit the event
transitioninitwhen that Scene'sinitmethod is called. It will then emit the eventtransitionstartwhen itscreatemethod is called. If the Scene was sleeping and has been woken up, it will emit the eventtransitionwakeinstead of these two, as the Scenesinitandcreatemethods are not invoked when a Scene wakes up.When the duration of the transition has elapsed it will emit the event
transitioncomplete. These events are cleared of all listeners when the Scene shuts down, but not if it is sent to sleep.It's important to understand that the duration of the transition begins the moment you call this method. If the Scene you are transitioning to includes delayed processes, such as waiting for files to load, the time still counts down even while that is happening. If the game itself pauses, or something else causes this Scenes update loop to stop, then the transition will also pause for that duration. There are checks in place to prevent you accidentally stopping a transitioning Scene but if you've got code to override this understand that until the target Scene completes it might never be unlocked for input events.
Parameters:
Name Type Description configPhaser.Types.Scenes.SceneTransitionConfig The transition configuration object.
- Since: 3.5.0
- Source: src/scene/ScenePlugin.js (Line 233)
Fires:
Returns:
trueis the transition was started, otherwisefalse.- Type
- boolean
-
wake( [key] [, data])
-
Makes the Scene wake-up (starts update and render)
This will happen at the next Scene Manager update, not immediately.
Parameters:
Name Type Argument Description keystring <optional>
The Scene to wake up.
dataobject <optional>
An optional data object that will be passed to the Scene and emitted in its wake event.
- Since: 3.0.0
- Source: src/scene/ScenePlugin.js (Line 566)
Returns:
This ScenePlugin object.
