Join Joseph Labrecque for an in-depth discussion in this video Adding countdown text, part of HTML5 Game Development with Phaser.
- View Offline
…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 last thing we need to do is say how big we want our text.…
- Downloading the Phaser framework
- Creating your first Phaser project
- Building the preloader and menu states
- Creating and spawning entities
- Working with particles and emitters
- Detecting and handling collisions
- Detecting "game over"
- Adding sound effects and text
- Preparing for mobile deployment