Jump to content

how to make game over text


roninkode
 Share

Recommended Posts

What is the simplest way to display "GAME OVER" once your game ends? I have this line of code:

let gameOverText = this.add.text(320, 240, 'GAME OVER', { fontSize: '32px', fill: '#fff' });

but I don't know where to put it for it to work. Right now, I just have the message logging to the console and it works fine. I think its the "this" that's messing me up. Any ideas?

Link to comment
Share on other sites

Hope this help you

// Display word "Game Over" at center of the screen game
let gameOverText = this.add.text(game.config.width / 2, game.config.height / 2, 'GAME OVER', { fontSize: '32px', fill: '#fff' });

// Set z-index just in case your text show behind the background.
gameOverText.setDepth(1);

 

Link to comment
Share on other sites

On 8/16/2018 at 6:24 AM, roninkode said:

but I don't know where to put it for it to work. Right now, I just have the message logging to the console and it works fine. I think its the "this" that's messing me up. Any ideas?

Have you done the Phaser 3 tutorial on the official website? Without doing it and not having JS fundamentals, you probably can't get far.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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