Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Game Development with Phaser!
You have completed Game Development with Phaser!
Preview
Learn how to organize your code into modular components called prefabs, that can be easily reused and maintained, improving overall code structure of our game.
Solution code:
const gameOverTitle = this.add.text(
1920 / 2,
840,
'GAME OVER',
{
fontSize: '100px',
fontStyle: 'bold',
},
).setOrigin(0.5, 0).setScrollFactor(0);
gameOverTitle.alpha = 0;
const gameOverTitleFadeIn = this.tweens.add({
targets: gameOverTitle,
alpha: 1,
y: 300,
duration: 200,
paused: true,
});
const gameOverText = this.add.text(
1920 / 2,
540,
'Press R to restart',
{
fontSize: '50px',
fontStyle: 'bold',
},
).setOrigin(0.5, 0).setScrollFactor(0);
gameOverText.alpha = 0;
const gameOverTextFadeIn = this.tweens.add({
targets: gameOverText,
alpha: 1,
duration: 200,
delay: 200,
paused: true,
});
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
we'll go through that in this video.
0:00
We're also going to refactor our code
by breaking things up into prefabs.
0:02
But for now,
let's go through the game over text.
0:06
If you didn't attempt to add
the text yourself, don't worry,
0:09
I've added my solution to the notes
tab at the bottom of this video.
0:13
Okay, let's scroll down to
the bottom of the create method, and
0:17
you'll see the new code that
I've added looks very familiar.
0:22
Let's quickly go over it.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up