This page is work-in-progress. You can reach me on twitter or mail to rezoner1337@gmail.com

Reference

var app = playground({

  width: 640,           /* force width */
  height: 480,          /* force height */
  scale: 2,             /* force scale */
  smoothing: false,     /* antialiasing */

  /* silently preload assets before main loader */

  preload: function() { },

  /* assets from preloader available, push some more for main loader */

  create: function() { },

  /* called when main loader has finished  - you want to setState here */

  ready: function() { },

  /* called after container/window has been resized */

  resize: function() { },

  /* called each frame to update logic */

  step: function(dt) { },

  /* called each frame to update rendering */

  render: function(dt) { },

  /* states related events (called only for application */

  createstate: function() { },
  enterstate: function() { },
  leavestate: function() { },

  /* keyboard events */

  keydown: function(data) { },
  keyup: function(data) { },

  /* pointers (mouse and touches) */

  pointerdown: function(data) { },
  pointerup: function(data) { },
  pointermove: function(data) { },

  /* mouse trap */

  mousedown: function(data) { },
  mouseup: function(data) { },
  mousemove: function(data) { },

  /* finger trap - ouch */

  touchstart: function(data) { },
  touchend: function(data) { },
  touchmove: function(data) { },

  /* gamepad events */

  gamepaddown: function(data) { },
  gamepadup: function(data) { },
  gamepadmove: function(data) { }

});

Application life cycle

preload is called - you can load some basics assets without loading screen

-- time passes --

create is called - you can load more assets that will go through proper loading screen

-- time passes --

ready is called - all assets available - you can now switch the state - events has been unlocked.

Event life cycle

When event such as mousedown is emmited this is what happens:

  1. Method mousedown is called if present in application
  2. Method mousedown is called if present in current state

Local events

Events that are not being passed to current state:

create, ready, createstate, enterstate, leavestate

State events

State has some events on its own.

create, enter, leave

And that's why create from application should not flow to the state.

Ask question:

Fork me on GitHub