new SceneManager(game, sceneConfig)
Parameters:
Name | Type | Description |
---|---|---|
game |
Phaser.Game | The Phaser.Game instance this Scene Manager belongs to. |
sceneConfig |
object | Scene specific configuration settings. |
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 17)
Members
-
customViewports :number
-
Do any of the Cameras in any of the Scenes require a custom viewport? If not we can skip scissor tests.
Type:
- number
- Since: 3.12.0
- Default Value:
-
- 0
- Source: src/scene/SceneManager.js (Line 128)
-
game :Phaser.Game
-
The Game that this SceneManager belongs to.
Type:
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 39)
-
<readonly> isBooted :boolean
-
Has the Scene Manager properly started?
Type:
- boolean
- Since: 3.4.0
- Default Value:
-
- false
- Source: src/scene/SceneManager.js (Line 117)
-
<readonly> isProcessing :boolean
-
Is the Scene Manager actively processing the Scenes list?
Type:
- boolean
- Since: 3.0.0
- Default Value:
-
- false
- Source: src/scene/SceneManager.js (Line 106)
-
keys :object
-
An object that maps the keys to the scene so we can quickly get a scene from a key without iteration.
Type:
- object
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 48)
-
scenes :array
-
The array in which all of the scenes are kept.
Type:
- array
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 57)
Methods
-
add(key, sceneConfig [, autoStart] [, data])
-
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:- A
Phaser.Scene
object, or an object that extends it. - A plain JavaScript object
- A JavaScript ES6 Class that extends
Phaser.Scene
- A JavaScript ES5 prototype based Class
- A JavaScript function
If a function is given then a new Scene will be created by calling it.
Parameters:
Name Type Argument Default Description key
string A unique key used to reference the Scene, i.e.
MainMenu
orLevel1
.sceneConfig
Phaser.Scene | Phaser.Types.Scenes.SettingsConfig | Phaser.Types.Scenes.CreateSceneFromObjectConfig | function The config for the Scene
autoStart
boolean <optional>
false If
true
the Scene will be started immediately after being added.data
object <optional>
Optional data object. This will be set as
Scene.settings.data
and passed toScene.init
, andScene.create
.- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 297)
Returns:
The added Scene, if it was added immediately, otherwise
null
.- Type
- Phaser.Scene
- A
-
bringToTop(key)
-
Brings a Scene to the top of the Scenes list.
This means it will render above all other Scenes.
Parameters:
Name Type Description key
string | Phaser.Scene The Scene to move.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1296)
Returns:
This SceneManager.
-
destroy()
-
Destroy the SceneManager and all of its Scene's systems.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1610)
-
dump()
-
Dumps debug information about each Scene to the developer console.
- Since: 3.2.0
- Source: src/scene/SceneManager.js (Line 1586)
-
getAt(index)
-
Retrieves a Scene by numeric index.
Parameters:
Name Type Description index
number The index of the Scene to retrieve.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1264)
Returns:
The Scene.
- Type
- Phaser.Scene | undefined
-
getIndex(key)
-
Retrieves the numeric index of a Scene.
Parameters:
Name Type Description key
string | Phaser.Scene The key of the Scene.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1279)
Returns:
The index of the Scene.
- Type
- number
-
getScene(key)
-
Retrieves a Scene.
Parameters:
Name Type Description key
string | Phaser.Scene The Scene to retrieve.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 867)
Returns:
The Scene.
- Type
- Phaser.Scene
-
getScenes( [isActive] [, inReverse])
-
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.
Parameters:
Name Type Argument 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?
- Since: 3.16.0
- Source: src/scene/SceneManager.js (Line 832)
Returns:
An array containing all of the Scenes in the Scene Manager.
- Type
- Array.<Phaser.Scene>
-
isActive(key)
-
Determines whether a Scene is running.
Parameters:
Name Type Description key
string The Scene to check.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 900)
Returns:
Whether the Scene is running.
- Type
- boolean
-
isPaused(key)
-
Determines whether a Scene is paused.
Parameters:
Name Type Description key
string The Scene to check.
- Since: 3.17.0
- Source: src/scene/SceneManager.js (Line 922)
Returns:
Whether the Scene is paused.
- Type
- boolean
-
isSleeping(key)
-
Determines whether a Scene is sleeping.
Parameters:
Name Type Description key
string The Scene to check.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 966)
Returns:
Whether the Scene is sleeping.
- Type
- boolean
-
isVisible(key)
-
Determines whether a Scene is visible.
Parameters:
Name Type Description key
string The Scene to check.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 944)
Returns:
Whether the Scene is visible.
- Type
- boolean
-
moveAbove(keyA, keyB)
-
Moves a Scene so it is immediately above another Scene in the Scenes list.
This means it will render over the top of the other Scene.
Parameters:
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.
- Since: 3.2.0
- Source: src/scene/SceneManager.js (Line 1432)
Returns:
This SceneManager.
-
moveBelow(keyA, keyB)
-
Moves a Scene so it is immediately below another Scene in the Scenes list.
This means it will render behind the other Scene.
Parameters:
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.
- Since: 3.2.0
- Source: src/scene/SceneManager.js (Line 1476)
Returns:
This SceneManager.
-
moveDown(key)
-
Moves a Scene down one position in the Scenes list.
Parameters:
Name Type Description key
string | Phaser.Scene The Scene to move.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1364)
Returns:
This SceneManager.
-
moveUp(key)
-
Moves a Scene up one position in the Scenes list.
Parameters:
Name Type Description key
string | Phaser.Scene The Scene to move.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1398)
Returns:
This SceneManager.
-
pause(key [, data])
-
Pauses the given Scene.
Parameters:
Name Type Argument Description key
string The Scene to pause.
data
object <optional>
An optional data object that will be passed to the Scene and emitted by its pause event.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 988)
Returns:
This SceneManager.
-
processQueue()
-
Process the Scene operations queue.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 244)
-
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 Description key
string A unique key used to reference the Scene, i.e.
MainMenu
orLevel1
.- Since: 3.2.0
- Source: src/scene/SceneManager.js (Line 388)
Returns:
This SceneManager.
-
render(renderer)
-
Renders the Scenes.
Parameters:
Name Type Description renderer
Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer The renderer to use.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 570)
-
resume(key [, data])
-
Resumes the given Scene.
Parameters:
Name Type Argument Description key
string The Scene to resume.
data
object <optional>
An optional data object that will be passed to the Scene and emitted by its resume event.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1011)
Returns:
This SceneManager.
-
run(key [, data])
-
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, thenrun
on the modal Scene.Parameters:
Name Type Argument Description key
string The Scene to run.
data
object <optional>
A data object that will be passed to the Scene on start, wake, or resume.
- Since: 3.10.0
- Source: src/scene/SceneManager.js (Line 1080)
Returns:
This Scene Manager.
-
sendToBack(key)
-
Sends a Scene to the back of the Scenes list.
This means it will render below all other Scenes.
Parameters:
Name Type Description key
string | Phaser.Scene The Scene to move.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1330)
Returns:
This SceneManager.
-
sleep(key [, data])
-
Puts the given Scene to sleep.
Parameters:
Name Type Argument Description key
string 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.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1034)
Returns:
This SceneManager.
-
start(key [, data])
-
Starts the given Scene.
Parameters:
Name Type Argument Description key
string The Scene to start.
data
object <optional>
Optional data object to pass to
Scene.Settings
andScene.init
, andScene.create
.- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1131)
Returns:
This SceneManager.
-
stop(key [, data])
-
Stops the given Scene.
Parameters:
Name Type Argument Description key
string The Scene to stop.
data
object <optional>
Optional data object to pass to Scene.shutdown.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1208)
Returns:
This SceneManager.
-
swapPosition(keyA, keyB)
-
Swaps the positions of two Scenes in the Scenes list.
Parameters:
Name Type Description keyA
string | Phaser.Scene The first Scene to swap.
keyB
string | Phaser.Scene The second Scene to swap.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1547)
Returns:
This SceneManager.
-
switch(from, to)
-
Sleeps one one Scene and starts the other.
Parameters:
Name Type Description from
string The Scene to sleep.
to
string The Scene to start.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1231)
Returns:
This SceneManager.
-
update(time, delta)
-
Updates the Scenes.
Parameters:
Name Type Description time
number Time elapsed.
delta
number Delta time from the last update.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 543)
-
wake(key [, data])
-
Awakens the given Scene.
Parameters:
Name Type Argument Description key
string 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.
- Since: 3.0.0
- Source: src/scene/SceneManager.js (Line 1057)
Returns:
This SceneManager.