Skip to content

4. The State Class

Eric edited this page Feb 14, 2017 · 3 revisions

The State Class

This is a very short review of the state class of Phaser. You can find an example in this repository in the following folder: tutorial-examples/spriteClass/scripts/GameState.ts.

Basically this class is easy to understand. Each game has different states, e.g. main menu, game, pause menu, etc. It is important to know at which point which functions are called within the state.

The following order may be accepted:

Init() -> preload() -> loadUpdate() -> loadRender() -> create() -> update() -> preRender() -> render()

Further states are, which are carried out with corresponding action:

Paused(), pauseUpdate(), resize(), resumed(), shutdown()

You will find all the details about the states and when which actions should be carried out in the GameState.ts file or on the official Phaser website.

Clone this wiki locally