From the course: HTML5 Game Development with Phaser

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Adding countdown text

Adding countdown text

From the course: HTML5 Game Development with Phaser

Start my 1-month free trial

Adding countdown text

We'll now create an ever-present piece of text, which will let the player know how many bunnies remain while playing the game. Once this number reaches zero, the game will end. So inside of game.JS, the first thing we need to do is declare a reference to our bitmap text for this. So this will be called this.countdown. Scrolling down to our build world function. Here we'll actually create that bitmap text. So to do that, immediately after emitter, we'll say this.countdown, and set that equal to this.addbitmapText. And here we'll position this ten pixels from the left, ten pixels from the top. We'll use our eight bit wonder bitmap font. And what do we want to put in here? We want to put the message that this is how many, actually, bunnies are left. So to do that, we'll say bunnies left, and then we'll append the actual count from our game. So to do that, we have totalBunnies, and we'll just put that right there. So now it'll concatenate both bunnies left with our total bunny count. The…

Contents