Display Game Over Score

4 minutes
Share the link to this page
Copied
  Completed
It is important that the user knows what there final score was, so let's add it to our game over scene.

Transcript

Hello, welcome to the 15th tutorial on the calcasieu, the expletive versatile plus series, and this power limiter can display in the game over school. We'll be continuing on from the previous tutorial. If you don't have the source code, don't worry, there'll be a link in the description to it. So we have the score displayed below and the game over same unfortunately, but fortunately, if we will actually implement it in this tutorial, firstly, your create a score variable inside the game overseeing CPP as a global variable. So let's go to a team over c ratar. o.

And the reason we're going to be creating a global variable and not something in the header is because we're going to pass a variable into the creating because this class hasn't been fully initialized at that point. We need a global variable so we can store it. So on and so forth school. And now let's modify the crediting method to taken on science And so this internet trade in school, we can copy and paste this and this also needs to go in here that we will now assign a temp score to the variable at the start with creating functions. So here, we're going to use go equals tank score. Now let's create a string of the score that will be used to create a label to be displayed within the scene.

So what we're gonna do is down here, we can actually copy and paste from a game on the scene. So this one right here. This is This month we have modified the or updated it, but we'll do that in a moment. So if you just go to our gaming scene, that'd be great. And in here we just copy and paste that. That should be a okay.

So what we're going to do is auto current score equals label GTF colon colon create to be a capital F. And for the string, we're going to have that I put this before I created the score string. So in here we're going to put 10th School get C string, then for the font and then I put funds for slash more TT now for the size of input with the bore size dot, height, by score, font size, semi colon, and now we can set the position the label which will be centered in the workers with 25% along the x axis as in the next tutorial. We will have a high score label which will be situated at 5% along the x axis. So what we're going to do is current school mission I'm going to point visible signs off with time but you're appointed to find origin dot x with ball size dot height divided by two plus origin dot y.

And now we can add this to our team. So show your current score on the only thing left to do within our games in the CPP here in the school variable, so with a specified score, there, and now we can run this and we can play our game. And when we die, we'll go to the game overseen as we always do, but we'll have that displayed. So lessons, let it load, click the play button. We have zero scope and score one score another point analysis done let me have the number to display there. So that is it for this tutorial.

In the next part of this series we're gonna be looking at actually saving the score because at the moment they're not shown right now if we click play, and we just let it for and we have zero because at the moment no score is sake. So like I said in the next tutorial, we'll be saving the score. If you have any questions feel free to message us support our solar systems Dakota UK, the email woman the description you can comment on this video or just directly messages via YouTube, or the recordings or source code will also be in the description. And as usual, thanks for watching and hope you have a nice day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.