summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2014-08-23 12:18:34 +0200
committerJustin Worthe <justin.worthe@gmail.com>2014-08-23 12:18:34 +0200
commit8c0a371916effa25ac77dc8a3420b95bd8b7a173 (patch)
tree8c0b17293d4289645da5a3399f36a811e698a1fd
parent9f30e7581f4f4ea5aea06467daca3083f60e4714 (diff)
Changed turn changing to only happen at the end of a players movement
-rw-r--r--game/prefabs/player.js8
-rw-r--r--game/states/play.js3
2 files changed, 8 insertions, 3 deletions
diff --git a/game/prefabs/player.js b/game/prefabs/player.js
index 344793b..40fce38 100644
--- a/game/prefabs/player.js
+++ b/game/prefabs/player.js
@@ -46,13 +46,19 @@ Player.prototype.update = function() {
}
};
-Player.prototype.move = function(newX, newY) {
+Player.prototype.move = function(newX, newY, callback, callbackContext) {
this.moving = true;
var tween = this.game.add.tween(this).to({x: newX, y: newY}, 500);
tween.onComplete.add(this.finishMovement, this);
+ tween.onComplete.add(callback, callbackContext);
tween.start();
};
+Player.prototype.teleport = function(newX, newY) {
+ this.x = newX;
+ this.y = newY;
+}
+
Player.prototype.finishMovement = function() {
this.moving = false;
};
diff --git a/game/states/play.js b/game/states/play.js
index 1b59596..7ffcc3d 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -210,8 +210,7 @@ Play.prototype = {
var newY = player.y + deltaY;
if (!this.checkMap(newX, newY) && player.isMyTurn && !player.moving) {
- player.move(newX, newY);
- this.togglePlayerTurn();
+ player.move(newX, newY, this.togglePlayerTurn, this);
}
},
playerPillCollision: function(player, pill) {