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
-
- Source:
Properties:
Name Type Description currentstring The current active State object (defaults to null).
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game A reference to the currently running game.
-
onCreateCallback
-
- Source:
Properties:
Name Type Description onCreateCallbackfunction This will be called when create states (setup states...).
-
onInitCallback
-
- Source:
Properties:
Name Type Description onInitCallbackfunction This will be called when the state is started (i.e. set as the current active state).
-
onLoadRenderCallback
-
- Source:
Properties:
Name Type Description onLoadRenderCallbackfunction This will be called when the State is rendered but only during the load process.
-
onLoadUpdateCallback
-
- Source:
Properties:
Name Type Description onLoadUpdateCallbackfunction This will be called when the State is updated but only during the load process.
-
onPausedCallback
-
- Source:
Properties:
Name Type Description onPausedCallbackfunction This will be called when the state is paused.
-
onPreloadCallback
-
- Source:
Properties:
Name Type Description onPreloadCallbackfunction This will be called when init states (loading assets...).
-
onPreRenderCallback
-
- Source:
Properties:
Name Type Description onPreRenderCallbackfunction This will be called before the State is rendered and before the stage is cleared.
-
onRenderCallback
-
- Source:
Properties:
Name Type Description onRenderCallbackfunction This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback).
-
onShutDownCallback
-
- Source:
Properties:
Name Type Description onShutDownCallbackfunction This will be called when the state is shut down (i.e. swapped to another state).
-
onUpdateCallback
-
- Source:
Properties:
Name Type Description onUpdateCallbackfunction This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback).
-
states
-
- Source:
Properties:
Name Type Description statesObject The object containing Phaser.States.
Methods
-
add(key, state, autoStart)
-
Add a new State.
Parameters:
Name Type Description keystring A unique key you use to reference this state, i.e. "MainMenu", "Level1".
stateState The state you want to switch to.
autoStartboolean Start the state immediately after creating it? (default true)
- Source:
-
checkState(key) → {boolean}
-
Description.
Parameters:
Name Type Description keystring 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 keystring State key.
- Source:
-
<protected> loadComplete()
-
- Source:
-
<protected> pause()
-
- Source:
-
<protected> preRender()
-
- Source:
-
remove(key)
-
Delete the given state.
Parameters:
Name Type Description keystring A unique key you use to reference this state, i.e. "MainMenu", "Level1".
- Source:
-
<protected> render()
-
- Source:
-
<protected> resume()
-
- Source:
-
<protected> setCurrentState(key)
-
Sets the current State. Should not be called directly (use StateManager.start)
Parameters:
Name Type Description keystring State key.
- Source:
-
start(key, clearWorld, clearCache)
-
Start the given state
Parameters:
Name Type Argument Description keystring The key of the state you want to start.
clearWorldboolean <optional>
clear everything in the world? (Default to true)
clearCacheboolean <optional>
clear asset cache? (Default to false and ONLY available when clearWorld=true)
- Source:
-
<protected> update()
-
- Source: