Skip to content

Commit b78984f

Browse files
added game score counter
1 parent 16ce5a1 commit b78984f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

public/src/games/breakout/breakout.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var Breakout = new Phaser.Class({
1111
this.bricks;
1212
this.paddle;
1313
this.ball;
14+
this.score=0;
15+
this.scoreText;
1416
},
1517

1618
preload: function ()
@@ -61,11 +63,17 @@ var Breakout = new Phaser.Class({
6163
}
6264

6365
}, this);
66+
67+
// Score components
68+
this.scoreText = this.add.text(32, 550, 'Score: 0', { font: "20px Arial", fill: "#ffffff", align: "left" });
6469
},
6570

6671
hitBrick: function (ball, brick)
6772
{
68-
brick.disableBody(true, true);
73+
this.score+=10;
74+
this.scoreText.setText("Score: "+this.score);
75+
76+
brick.disableBody(true, true);
6977

7078
if (this.bricks.countActive() === 0)
7179
{

0 commit comments

Comments
 (0)