diff options
author | Justin Worthe <justin.worthe@gmail.com> | 2014-08-23 19:18:36 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@gmail.com> | 2014-08-23 19:18:36 +0200 |
commit | a9e90a7b708e52a8875530eb00313146b43a9926 (patch) | |
tree | aba9b64817089bb55df7ac939e4ca895aad496cd /game/prefabs | |
parent | e74950e005d89fe2fd8453a78d84f26e4e93dada (diff) |
Added wrapping of game world
Diffstat (limited to 'game/prefabs')
-rw-r--r-- | game/prefabs/player.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/game/prefabs/player.js b/game/prefabs/player.js index e33b109..a4d1b57 100644 --- a/game/prefabs/player.js +++ b/game/prefabs/player.js @@ -46,12 +46,27 @@ Player.prototype.update = function() { 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(callback, callbackContext); tween.onComplete.add(this.finishMovement, this); + tween.start(); }; +Player.prototype.multistepMove = function(moveX, moveY, teleportX, teleportY, finalX, finalY, callback, callbackContext) { + this.moving = true; + + var firstTween = this.game.add.tween(this).to({x: moveX, y: moveY}, 500); + + firstTween.onComplete.add(function() { + this.teleport(teleportX, teleportY); + this.move(finalX, finalY, callback, callbackContext); + }, this); + + firstTween.start(); +} + Player.prototype.teleport = function(newX, newY) { this.x = newX; this.y = newY; |