From 0a4b32158d6ddd17eb9df21ff5940c736eb8208e Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Thu, 31 Jul 2014 16:45:33 +0200 Subject: Attempt at adding orientation based input --- game/states/play.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'game/states/play.js') diff --git a/game/states/play.js b/game/states/play.js index 1c4a926..6ea7611 100644 --- a/game/states/play.js +++ b/game/states/play.js @@ -183,6 +183,19 @@ Play.prototype = { addKeyCaptures(this.playerBControls, this.game.input.keyboard); this.game.input.gamepad.start(); + + this.game.orientation.onLeft.add(function() { + this.movePlayer(this.players.children[this.playerTurn], -1, 0); + }, this); + this.game.orientation.onRight.add(function() { + this.movePlayer(this.players.children[this.playerTurn], 1, 0); + }, this); + this.game.orientation.onUp.add(function() { + this.movePlayer(this.players.children[this.playerTurn], 0, -1); + }, this); + this.game.orientation.onDown.add(function() { + this.movePlayer(this.players.children[this.playerTurn], 0, 1); + }, this); }, movePlayer: function(player, deltaX, deltaY) { var newX = player.x + deltaX; -- cgit v1.2.3