Join Joseph Labrecque for an in-depth discussion in this video Detecting game-over, part of HTML5 Game Development with Phaser.
…Once all of our bunnies are lost to collisions,…there's nothing more to defend, so game over.…We need to set a boolean to keep track of whether the game has ended or not, and…can use this variable throughout our game to control when certain actions occur.…So, at the top of Game.js, we're going to set that boolean as this.gameover.…Within our create function, the first thing we want to do is make sure…that this dot game over is set to false before anything else happens in our game.…
In certain conditions, we're going to want to restrict whether something happens or…not based upon game over,…because if the game is over we don't want to respond rocks anymore.…We don't want to allow the user to fire explosions anymore.…It doesn't make sense.…So, let's go down to our respawnRock function.…That's right here.…And all we need to do is wrap this in an if statement.…So we'll say if this.gameover is equal to false.…Then we want to be able to actually respawn the rocks.…If game over is true, we don't want this to ever execute.…
- 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
Skill Level Beginner
1. Setting Up Phaser
2. Configuring Loaders and States
3. Populating the World
5. Wrapping Things Up
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.