Class: States

States


new States(canvas, ticker)

Preloads, updates, and cleans up the various game states
Accepts an object of the following schema:

{
// optional property of paths to assets to preload
preload: [
'path/to/assets',
...
],
init: function () {
// initialize entities etc.
},
render: function (factor, ticks) {
// do stuff on every tick
},
destroy: function () {
// remove event listeners
}
}

Parameters:
Name Type Description
canvas Canvas

A Canvas instance

ticker Ticker

A ticker instance

Author:
  • Chris Peters
Source:
Requires:

Requires

Methods


_onTick(e)

Calls the current state's update function. Passes the factor and ticks from Ticker

Parameters:
Name Type Description
e Object

The event object

Source:

load()

Set up (and preload if necessary) a state

Source:
Returns:

The state to load

Type
State