Skip to content
whirlibulf edited this page May 8, 2013 · 4 revisions

A system can have an update method and/or a render method.

Here is the basic outline for a system:

function System() {
}

System.prototype.init = function (engine) {
  console.log('System loaded');
  this.engine = engine;
};

System.prototype.update = function (dt) {
  //Do stuff here
};

System.prototype.render = function () {
  //Or do stuff here, if this system does rendering
};

The init function is called when the system has been added to the game. It is called with a reference to the engine, so that the system can call the engine API.