How to make gameover + try again

Recommended Posts

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

    //  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.

Share this post

Link to post
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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.