Skip to content

Commit

Permalink
adding events
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Distad committed Oct 22, 2009
1 parent 8035a35 commit 14dfbc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion game.js
Expand Up @@ -7,7 +7,7 @@ Game = {
RIGHT: 39,
UP: 38,
DOWN: 40
};
}

Game.keyBindings = function(e) {
switch(e.which) {
Expand Down
4 changes: 4 additions & 0 deletions player.js
Expand Up @@ -8,20 +8,24 @@ function Player() {
this.moveLeft = function() {
this._x -= this._moveDistance;
this._avatar.animate({ cx: this._x }, this._moveTime);
this._avatar.node.trigger('player:moveleft')
}

this.moveRight = function() {
this._x += this._moveDistance;
this._avatar.animate({ cx: this._x }, this._moveTime);
this._avatar.node.trigger('player:moveright')
}

this.moveUp = function() {
this._y -= this._moveDistance;
this._avatar.animate({ cy: this._y }, this._moveTime);
this._avatar.node.trigger('player:moveup')
}

this.moveDown = function() {
this._y += this._moveDistance;
this._avatar.animate({ cy: this._y }, this._moveTime);
this._avatar.node.trigger('player:movedown')
}
};

0 comments on commit 14dfbc6

Please sign in to comment.