Skip to content

Instantly share code, notes, and snippets.

@allouis
Created December 7, 2014 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allouis/44cc76667241e9eb3313 to your computer and use it in GitHub Desktop.
Save allouis/44cc76667241e9eb3313 to your computer and use it in GitHub Desktop.
var PlayerController = function PlayerController(opts) {
this.model = PlayerModel.create({
blah: 'blah'
});
keyCodes.on('keyDown', function (direction) {
this[direction]();
}, this); // third arg is context of `this`
};
PlayerController.prototype = {
up: function () {
this.model.velY = 1;
}
}
exports.create = function create(opts) {
return new PlayerController(opts);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment