new StateManager(game, pendingState)
The State Manager is responsible for loading, setting up and switching game states.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
||
pendingState |
Phaser.State | Object |
<optional> |
null | A State object to seed the manager with. |
- Source:
Members
-
current
-
The current active State object (defaults to null).
- Source:
Properties:
Name Type Description current
string -
game
-
A reference to the currently running game.
- Source:
Properties:
Name Type Description game.
Phaser.Game -
game
-
A reference to the currently running game.
- Source:
Properties:
Name Type Description game.
Phaser.Game -
onCreateCallback
-
This will be called when create states (setup states...).
- Source:
Properties:
Name Type Description onCreateCallback
function -
onInitCallback
-
This will be called when the state is started (i.e. set as the current active state).
- Source:
Properties:
Name Type Description onInitCallback
function -
onLoadRenderCallback
-
This will be called when the State is rendered but only during the load process.
- Source:
Properties:
Name Type Description onLoadRenderCallback
function -
onLoadUpdateCallback
-
This will be called when the State is updated but only during the load process.
- Source:
Properties:
Name Type Description onLoadUpdateCallback
function -
onPausedCallback
-
This will be called when states paused.
- Source:
Properties:
Name Type Description onPausedCallback
function -
onPreloadCallback
-
This will be called when init states (loading assets...).
- Source:
Properties:
Name Type Description onPreloadCallback
function -
onPreRenderCallback
-
This will be called before the State is rendered and before the stage is cleared.
- Source:
Properties:
Name Type Description onPreRenderCallback
function -
onRenderCallback
-
This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback).
- Source:
Properties:
Name Type Description onRenderCallback
function -
onShutDownCallback
-
This will be called when the state is shut down (i.e. swapped to another state).
- Source:
Properties:
Name Type Description onShutDownCallback
function -
onUpdateCallback
-
This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback).
- Source:
Properties:
Name Type Description onUpdateCallback
function -
states
-
Description.
- Source:
Properties:
Name Type Description states.
Description -
states
-
The state to be switched to in the next frame.
- Source:
Properties:
Name Type Description states
Description
Methods
-
add(key, state, autoStart)
-
Add a new State.
Parameters:
Name Type Description key
string A unique key you use to reference this state, i.e. "MainMenu", "Level1".
state
State The state you want to switch to.
autoStart
boolean Start the state immediately after creating it? (default true)
- Source:
-
checkState(key) → {boolean}
-
Description.
Parameters:
Name Type Description key
string The key of the state you want to check.
- Source:
Returns:
Description.
- Type
- boolean
-
destroy()
-
Nuke the entire game from orbit
- Source:
-
<protected> link(key)
-
Links game properties to the State given by the key.
Parameters:
Name Type Description key
string State key.
- Source:
-
<protected> loadComplete()
-
- Source:
-
<protected> preRender()
-
- Source:
-
remove(key)
-
Delete the given state.
Parameters:
Name Type Description key
string A unique key you use to reference this state, i.e. "MainMenu", "Level1".
- Source:
-
<protected> render()
-
- Source:
-
<protected> setCurrentState(key)
-
Sets the current State. Should not be called directly (use StateManager.start)
Parameters:
Name Type Description key
string State key.
- Source:
-
start(key, clearWorld, clearCache)
-
Start the given state
Parameters:
Name Type Argument Description key
string The key of the state you want to start.
clearWorld
boolean <optional>
clear everything in the world? (Default to true)
clearCache
boolean <optional>
clear asset cache? (Default to false and ONLY available when clearWorld=true)
- Source:
-
<protected> update()
-
- Source: