summaryrefslogtreecommitdiff
path: root/game/states/play.js
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2014-07-19 11:58:25 +0200
committerJustin Worthe <justin.worthe@gmail.com>2014-07-19 11:58:25 +0200
commit10d101e5fee782f6370c93ac2e39ebc96054ea4b (patch)
tree4904a8da7aded89b3d588ac43c0d64d13dbd3f5b /game/states/play.js
parent76c53168629511ec46124ed221044d210e4f87c6 (diff)
Fixed animation issue on players
Diffstat (limited to 'game/states/play.js')
-rw-r--r--game/states/play.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/game/states/play.js b/game/states/play.js
index aed4f90..1d13e0b 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -71,9 +71,9 @@ Play.prototype = {
}
},
readLevelFile: function() {
- this.walls = this.game.add.group();
this.pills = this.game.add.group();
this.players = this.game.add.group();
+ this.walls = this.game.add.group();
var levelText = this.game.cache.getText('level');
var splitRows = levelText.split('\n');
@@ -139,15 +139,23 @@ Play.prototype = {
this.game.input.keyboard.addKey(this.playerAControls.down).onDown.add(this.movePlayer.bind(this, this.playerA, 0, 1), this);
this.game.input.keyboard.addKey(this.playerAControls.left).onDown.add(this.movePlayer.bind(this, this.playerA, -1, 0), this);
this.game.input.keyboard.addKey(this.playerAControls.right).onDown.add(this.movePlayer.bind(this, this.playerA, 1, 0), this);
- padA.getButton(Phaser.Gamepad.XBOX360_DPAD_UP).onDown.add(this.movePlayer.bind(this, this.playerA, 0, -1), this);
- padA.getButton(Phaser.Gamepad.XBOX360_DPAD_DOWN).onDown.add(this.movePlayer.bind(this, this.playerA, 0, 1), this);
- padA.getButton(Phaser.Gamepad.XBOX360_DPAD_LEFT).onDown.add(this.movePlayer.bind(this, this.playerA, -1, 0), this);
- padA.getButton(Phaser.Gamepad.XBOX360_DPAD_RIGHT).onDown.add(this.movePlayer.bind(this, this.playerA, 1, 0), this);
+ if (padA.connected) {
+ padA.getButton(Phaser.Gamepad.XBOX360_DPAD_UP).onDown.add(this.movePlayer.bind(this, this.playerA, 0, -1), this);
+ padA.getButton(Phaser.Gamepad.XBOX360_DPAD_DOWN).onDown.add(this.movePlayer.bind(this, this.playerA, 0, 1), this);
+ padA.getButton(Phaser.Gamepad.XBOX360_DPAD_LEFT).onDown.add(this.movePlayer.bind(this, this.playerA, -1, 0), this);
+ padA.getButton(Phaser.Gamepad.XBOX360_DPAD_RIGHT).onDown.add(this.movePlayer.bind(this, this.playerA, 1, 0), this);
+ }
this.game.input.keyboard.addKey(this.playerBControls.up).onDown.add(this.movePlayer.bind(this, this.playerB, 0, -1), this);
this.game.input.keyboard.addKey(this.playerBControls.down).onDown.add(this.movePlayer.bind(this, this.playerB, 0, 1), this);
this.game.input.keyboard.addKey(this.playerBControls.left).onDown.add(this.movePlayer.bind(this, this.playerB, -1, 0), this);
this.game.input.keyboard.addKey(this.playerBControls.right).onDown.add(this.movePlayer.bind(this, this.playerB, 1, 0), this);
+ if (padB.connected) {
+ padB.getButton(Phaser.Gamepad.XBOX360_DPAD_UP).onDown.add(this.movePlayer.bind(this, this.playerB, 0, -1), this);
+ padB.getButton(Phaser.Gamepad.XBOX360_DPAD_DOWN).onDown.add(this.movePlayer.bind(this, this.playerB, 0, 1), this);
+ padB.getButton(Phaser.Gamepad.XBOX360_DPAD_LEFT).onDown.add(this.movePlayer.bind(this, this.playerB, -1, 0), this);
+ padB.getButton(Phaser.Gamepad.XBOX360_DPAD_RIGHT).onDown.add(this.movePlayer.bind(this, this.playerB, 1, 0), this);
+ }
},
movePlayer: function(player, deltaX, deltaY) {
var newX = player.x + deltaX;