summaryrefslogtreecommitdiff
path: root/game/states/play.js
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2014-08-31 14:17:06 +0200
committerJustin Worthe <justin.worthe@gmail.com>2014-08-31 14:17:06 +0200
commit25b5fb04067dcc65d1bbb76a99a919d92ceaab25 (patch)
tree35efb6a1a2c628fb1923b55a3bab65c036c45a38 /game/states/play.js
parent94892a4e24b5c7b9618d6d5ae3e676b11ae8896d (diff)
Added sound effect for player respawning
Diffstat (limited to 'game/states/play.js')
-rw-r--r--game/states/play.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/game/states/play.js b/game/states/play.js
index 4d6080b..99d29a1 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -341,6 +341,7 @@ Play.prototype = {
}
poisonPill.destroy();
+ player.respawnSound.play();
},
playerPlayerCollision: function(playerA, playerB) {
var eatenPlayer = playerA.isMyTurn ? playerB : playerA;
@@ -348,7 +349,13 @@ Play.prototype = {
var respawnX = Math.ceil(this.gameWidth/2)-1;
var respawnY = Math.ceil(this.gameHeight/2)-1;
- eatenPlayer.teleport(respawnX, respawnY);
+ if (eatenPlayer.lastTween) {
+ eatenPlayer.lastTween.onComplete.add(eatenPlayer.teleport.bind(eatenPlayer, respawnX, respawnY), eatenPlayer);
+ }
+ else {
+ eatenPlayer.teleport(respawnX, respawnY);
+ }
+ eatenPlayer.respawnSound.play();
},
togglePlayerTurn: function() {
this.updatePlayerTurn((this.playerTurn+1)%this.players.length);