diff options
author | Justin Worthe <justin.worthe@entelect.co.za> | 2014-05-28 17:06:10 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@entelect.co.za> | 2014-05-28 17:06:10 +0200 |
commit | 46b8f845e0e8ef4534a99e2d34b604f990ac217b (patch) | |
tree | 5390ff4c07c9b1f6a7b5ffb476a15cb3703bf7c5 /game/prefabs/player.js | |
parent | 7dfbd52a082b7a33c5f81b26da859830675223ba (diff) |
Hacked in changing player sprite based on turn
Diffstat (limited to 'game/prefabs/player.js')
-rw-r--r-- | game/prefabs/player.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/game/prefabs/player.js b/game/prefabs/player.js index 0f6cb18..3492836 100644 --- a/game/prefabs/player.js +++ b/game/prefabs/player.js @@ -2,7 +2,7 @@ var Player = function(game, x, y, key, frame) { Phaser.Sprite.call(this, game, x, y, key, frame); - + this.baseKey = key; this.moving = false; this.scale = {x: 0.01, y: 0.01}; this.anchor = {x: 0.5, y: 0.5}; @@ -16,7 +16,12 @@ var Player = function(game, x, y, key, frame) { Player.prototype = Object.create(Phaser.Sprite.prototype); Player.prototype.constructor = Player; -Player.prototype.update = function() { +Player.prototype.update = function() { + var newKey = this.baseKey + (this.isMyTurn ? '' : '-dim'); + if (this.key !== newKey) { + console.log('Setting sprite to ' + newKey); + this.loadTexture(newKey); + } }; Player.prototype.move = function(newX, newY) { |