summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2014-05-18 00:22:52 +0200
committerJustin Worthe <justin.worthe@gmail.com>2014-05-18 00:22:52 +0200
commit507541065c5e39e2259c5a1f300491f3e388c426 (patch)
tree782a7b2834a69eafbbb6c2fd515a8efc53d2f8dc
parent11f91c41c7fb47baa5c5100cd32949575e98f6aa (diff)
Added showing of scores
-rw-r--r--game/states/play.js6
-rw-r--r--game/states/preload.js2
2 files changed, 7 insertions, 1 deletions
diff --git a/game/states/play.js b/game/states/play.js
index 49c6cca..84237a6 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -43,6 +43,9 @@ Play.prototype = {
this.addPlayerControls();
this.game.physics.startSystem(Phaser.Physics.ARCADE);
+
+ this.playerAScoreText = this.game.add.bitmapText(-0.1, -0.4, 'scorefont','0',1);
+ this.playerBScoreText = this.game.add.bitmapText(this.world.width/100 - 2.1, -0.4, 'scorefont','0',1);
},
update: function() {
this.game.physics.arcade.overlap(this.players, this.pills, this.playerPillCollision, null, this);
@@ -179,7 +182,8 @@ Play.prototype = {
player.score++;
pill.destroy();
- console.log('A: ' + this.playerA.score + ' B: ' + this.playerB.score);
+ this.playerAScoreText.setText(this.playerA.score+'');
+ this.playerBScoreText.setText(this.playerB.score+'');
}
};
diff --git a/game/states/preload.js b/game/states/preload.js
index 945ad14..28420f7 100644
--- a/game/states/preload.js
+++ b/game/states/preload.js
@@ -16,6 +16,8 @@ Preload.prototype = {
this.load.image('player-a', 'assets/images/player-a.svg');
this.load.image('player-b', 'assets/images/player-b.svg');
this.load.image('pill', 'assets/images/pill.svg');
+
+ this.load.bitmapFont('scorefont', 'assets/fonts/scorefont.png', 'assets/fonts/scorefont.fnt', undefined, 10);
},
create: function() {
this.asset.cropEnabled = false;