1 decade ago by Skwiddy
Hi again,
n00b question. I am coding a breakout clone as a programming test and I've got quite far but I am struggling with updating the players score.
I declare my score variable in main.js and then have the following:
<code>
draw: function() {
// Draw all entities and backgroundMaps
this.parent();
this.font.draw( this.score.floor().toString(), ig.system.width -50, 50, ig.Font.ALIGN.RIGHT );
}
</code>
which seems to work fine. I increment score in my Tile entity like this:
<code>
hitTile: function() {
this.score += 1;
this.kill();
}
</code>
but the score isn't updating. Does the Tile entity know what 'score' is? Is there a better way of doing it?
n00b question. I am coding a breakout clone as a programming test and I've got quite far but I am struggling with updating the players score.
I declare my score variable in main.js and then have the following:
<code>
draw: function() {
// Draw all entities and backgroundMaps
this.parent();
this.font.draw( this.score.floor().toString(), ig.system.width -50, 50, ig.Font.ALIGN.RIGHT );
}
</code>
which seems to work fine. I increment score in my Tile entity like this:
<code>
hitTile: function() {
this.score += 1;
this.kill();
}
</code>
but the score isn't updating. Does the Tile entity know what 'score' is? Is there a better way of doing it?