summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {