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.

Bunny death

Bunny death

From the course: HTML5 Game Development with Phaser

Start my 1-month free trial

Bunny death

While we are currently decrementing our bunny count upon space rock collision or friendly fire, we have no real indicator of what just happened. A user may not understand that a bunny has been lost. To remedy this, we'll create a ghost which will speed toward the upper atmosphere post-impact. To do this, the first thing we need to do is load in the asset that will represent that. Moving over to our preloader, directly beneath the explosion inside of our preload function, we're going to say, this.load.image. And here, we'll tag this as ghost, so that we can identify it later. And this'll point to images/ghost.png. Popping back over to game.js, we'll now create this makeGhost function. So, let's go all the way down to, after our friendly fire function. And this is a lengthy function, so I will paste it in from the code snippets. And, we can see that makeGhost is a function or a passing in our particular bunny instance. The reason we're doing that is because we need to know the x and y…

Contents