From 507541065c5e39e2259c5a1f300491f3e388c426 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 18 May 2014 00:22:52 +0200 Subject: Added showing of scores --- game/states/play.js | 6 +++++- game/states/preload.js | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'game') 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; -- cgit v1.2.3