Namespace: state

game.state

Handles game states.
When a state is associated with an object it can accessed using game.state.start('state name').
That way the object can use the especial functions: preload(), create() and update(); that behave according to the following rules:
- preload() : first function to run when a state is called. Loads media. Runs only once. (is optional)
- create() : called right after preload(). Where the main code goes. Runs only once. (must exist)
- update() : called right after create(). Is iteratively called by 'game loop' until going to next state. (is optional)
Source:

Methods

(static) add(name, obj)

Create new state.
After a state is created, the object associated with that state can be called using game.state.start('state name')
Parameters:
Name Type Description
name string state name
obj object object that should be called when accessing the state
Source:

(static) create()

[Not directly used] Encapsulate create() function in the current state.
Source:

(static) start(name)

Start new state. Will look for the state's preload() to load the files for the current state. If there is no preload, will call create().
Parameters:
Name Type Description
name string state name
Source: