onShutDownCallback : Function

onStateChange is a Phaser.Signal that is dispatched whenever the game changes state.

It is dispatched only when the new state is started, which isn't usually at the same time as StateManager.start
is called because state swapping is done in sync with the game loop. It is dispatched before any of the new states
methods (such as preload and create) are called, and after the previous states shutdown method has been run.

The callback you specify is sent two parameters: the string based key of the new state,
and the second parameter is the string based key of the old / previous state.

states : Object

Public Methods

add(key, state, autoStart)

Adds a new State into the StateManager. You must give each State a unique key by which you'll identify it.
The State can be either a Phaser.State object (or an object that extends it), a plain JavaScript object or a function.
If a function is given a new state object will be created by calling it.

Parameters

Name

Type

Argument

Default

Description

key

string

A unique key you use to reference this state, i.e. "MainMenu", "Level1".

Parameters

Returns

clearCurrentState()

This method clears the current State, calling its shutdown callback. The process also removes any active tweens,
resets the camera, resets input, clears physics, removes timers and if set clears the world and cache too.