Class: StateManager

Phaser. StateManager

Phaser.StateManager

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

Properties:
Name Type Description
current string

The current active State object (defaults to null).

Source:

game

Properties:
Name Type Description
game Phaser.Game

A reference to the currently running game.

Source:

onCreateCallback

Properties:
Name Type Description
onCreateCallback function

This will be called when create states (setup states...).

Source:

onInitCallback

Properties:
Name Type Description
onInitCallback function

This will be called when the state is started (i.e. set as the current active state).

Source:

onLoadRenderCallback

Properties:
Name Type Description
onLoadRenderCallback function

This will be called when the State is rendered but only during the load process.

Source:

onLoadUpdateCallback

Properties:
Name Type Description
onLoadUpdateCallback function

This will be called when the State is updated but only during the load process.

Source:

onPausedCallback

Properties:
Name Type Description
onPausedCallback function

This will be called when the state is paused.

Source:

onPreloadCallback

Properties:
Name Type Description
onPreloadCallback function

This will be called when init states (loading assets...).

Source:

onPreRenderCallback

Properties:
Name Type Description
onPreRenderCallback function

This will be called before the State is rendered and before the stage is cleared.

Source:

onRenderCallback

Properties:
Name Type Description
onRenderCallback function

This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback).

Source:

onShutDownCallback

Properties:
Name Type Description
onShutDownCallback function

This will be called when the state is shut down (i.e. swapped to another state).

Source:

onUpdateCallback

Properties:
Name Type Description
onUpdateCallback function

This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback).

Source:

states

Properties:
Name Type Description
states Object

The object containing Phaser.States.

Source:

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}

Checks if a given phaser state is valid. State must exist and have at least one callback function registered..

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:

getCurrentState()

Gets the current State.

Source:
Returns:

Phaser.State

Links game properties to the State given by the key.

Parameters:
Name Type Description
key string

State key.

Source:

<protected> loadComplete()

Source:

<protected> pause()

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> resume()

Source:

start(key, clearWorld, clearCache)

Start the given State. If a State is already running then State.shutDown will be called (if it exists) before switching to the new State.

Parameters:
Name Type Argument Default Description
key string

The key of the state you want to start.

clearWorld boolean <optional>
true

Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly)

clearCache boolean <optional>
false

Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well.

Source:

<protected> update()

Source:
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Wed Feb 19 2014 05:26:32 GMT-0000 (GMT) using the DocStrap template.