Part 6 Add Dead Animation
When the bird dies, we restart the game right away. Instead, we are going to make the bird fall off the screen as a dead animation.
Now we create the new hitPipe() function.
hitPipe: function() {
// If the bird has already hit a pipe, we have nothing to do if (this.bird.alive == false) return; // Set the alive property of the bird to false this.bird.alive = false; // Prevent new pipes from appearing game.time.events.remove(this.timer); // Go through all the pipes, and stop their movement this.pipes.forEachAlive(function(p){ p.body.velocity.x = 0; }, this); }, |