Jump to content

How to make gameover + try again


Aleksander87
 Share

Recommended Posts

function collectStar (player, star) {
    
    // Removes the star from the screen
    star.kill();

    //  Add and update the score
    score += 10;
    scoreText.text = 'Score: ' + score;

    if(score === 120)
    {
        WHAT TO DO HERE??
        show text gameover and retry button (restart game)
    }

}

Hello. I'am newbie in Phaser. I just want to upgrade tutorial game with gameover and try again mode. I create if statement when player reach 120 points and next gameover text appear and retry/restart button. Please give me some advice.

Link to comment
Share on other sites

You can simply create a Phaser.Text object, set its visible property to false and set it to true on game end. There are of course some things to take care of, dependent on your project such as blocking player's input. You can do exactly the same with Phaser.Button that says Try Again. And just in onclick callback of the button reset whole scene.

Link to comment
Share on other sites

  • 8 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...