From a9e90a7b708e52a8875530eb00313146b43a9926 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sat, 23 Aug 2014 19:18:36 +0200 Subject: Added wrapping of game world --- game/prefabs/player.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'game/prefabs/player.js') 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; -- cgit v1.2.3