Welcome back.
Now we have a pretty nice looking opening main menu level, but we'd like to add more to it.
We need some buttons and I'd also like to add some music that would be really nice when we press play,
if we get some nice ambient music that makes us feel like we want to play the game.
Now for this, we could really use the aura main menu actor.
We could use the level blueprint.
I kind of like using actors in the world as opposed to the level blueprint.
So I'm going to open my aura main menu and go to its event graph.
And in begin play I'm going to simply play sound.
And we'll use Playsound 2D and we can simply play a sound.
And now what are we going to play?
Well, if we go to content assets sounds and into this folder called music, here's some music that
we have in our game project.
We can select that and we can simply play this sound.
Now I'm going to open up this sound though, and make sure that it's set to looping.
So if I check that looping check box then we'll just get that music looping.
And with that we can just play test and see how this feels with that music.
And I'm going to play it for a while to make sure it loops on itself.
So let's try this.
Okay.
So with that we have successful looping.
So that looks and sounds good and I'm happy with that.
I'm going to leave it like that.
And shout out to Carlos Jimenez for making this music and all the sounds for this game project.
So reach out to Carlos if you need some professional sounds.
I really appreciate Carlos making these sound effects.
It really adds a lot to the game project.
So now that we have sound check, now we need buttons.
So we're going to make another widget.
And for this we can go into blueprints UI.
And we're going to make a new folder here we'll call this main menu.
And we'll add a new widget blueprint here.
So let's go ahead and make one I'm going to go to User Interface Widget Blueprint.
And we really don't need an Ora user widget for this either.
We're just going to want two buttons a play button and a quit button.
So I'm going to choose User Widget and call this Wbhp.
Main menu.
And our main menu is going to be super, super basic.
It's going to have a canvas panel, something that we use sparingly.
Right.
Only our overlay in this project has one.
Well we're going to use one for the main menu as well.
It's okay to use a canvas panel.
In this case we're going to go ahead and add a couple things.
We're going to get a wide button.
The wide button is our nice special red button.
And we can size it how we want it to be sized.
And we can put a nice message here.
We can say play.
We can even give it some different settings, such as a font size, maybe 26, maybe 28.
We can give it more letter spacing if we like.
I think that looks pretty nice, and I'm going to make sure that it's anchored to the center and the
bottom.
And I'm going to set its alignment in the X to point five.
That way, if I set its position x to zero, it goes to the middle.
But I don't want its position x to zero.
I want it off to the left a little bit, because I want a button to the right as well.
I'm going to give its position x -250.
And then I'm going to add another wide button.
Now I'm going to take this first wide button.
And I'm going to copy its properties over.
So I'd like its size and all that to be the same.
Now its size is 166.
I'm going to make it 160 to have a nice even number and 85 and I'll use 160 and 85 for this other button,
160 for size x 85 for size y.
And I'm going to copy its y position.
Its -177 but I'm going to make it -180.
And I'm going to set that here position y.
Now before I do that actually I need to anchor it to the bottom center and set its alignment to 0.5
and the X.
That way we're working with similar values.
And now I can set position y.
Copy that over.
And position x I'm going to set to positive 250 because the other one is -250.
Now we have equidistance from the center.
Okay.
So let's use the same font settings as well.
So we had a font size of 28.
Letter spacing can be 400.
So 28 and 400 here 28 for the font size 400 for letter spacing.
And it looks like that's going to be well we don't know if it's too much because we only want four letters.
Play and quit.
Both have four letters each.
So that works perfectly.
Let's see how this looks.
If we add this now how are we going to add this.
Well we could do it really in the level blueprint.
We could do it in or a main menu.
Since we're handling most of our things in or a main menu, that would probably be a good place.
Here in our main menu we can call Create Widget.
We can select the main menu widget WB main menu, and we can add it to the viewport.
So add to viewport.
Now another thing I'd like to do is I'd like to.
Not be able to move, which means we need to set our input mode to UI only and set our widget to focus.
Now I'm going to call Get Player Controller.
This will get us the player controller.
This allows us to call set input mode and I'm going to choose UI only.
And for the widget to focus, we're going to use the main menu.
And I'll also take the player controller and call set show mouse cursor.
We're going to set this to true so we can still see the mouse cursor.
And with that.
Let's press play.
Now we can't full screen because we can't click in here and focus, but we can click on the buttons.
And that's great.
So things are looking pretty nice there.
And we just want these buttons to be functional.
So for now I'm done with our main menu.
I'm done with the title widget.
I'm done with the music.
But here in the main menu I want to assign to the on clicked events here.
So I'm going to go to the graph.
And in event construct, this is a good enough place to assign on clicked events to both of these,
which now need to be set as variables.
So is variable is set for both of them and we should give them meaningful names.
This is going to be button.
Play.
And then this one is going to be button quit.
All right, let's save and go back to the graph and we'll first do the quit button.
We're going to get button quit.
Remember this is a WPP wide button.
And it has a button.
So we need to get the button and assign to the buttons on clicked.
So once we assign on clicked then right here in our event we can decide what happens.
And this is the quit button.
So I just want to quit game.
We're going to call quit game.
Simple as that.
Now for the button play.
We're going to bring that in.
We're going to get button.
And assigned to its onclicked.
And what are we going to do for this one?
Well, I'd like to open a level.
I'd like to go into the next level, which looks different.
Perhaps it may be the same area, but without aura there either case I want to change to a different
level.
And that level is going to be where we load up our progress or choose to play a new game with a brand
new character.
So I'm going to need a new map.
So I'm going to go to the maps folder and I'm going to take this main menu.
By the way, I should save all and I'm going to duplicate this main menu.
I'm going to duplicate it and call this load menu.
So we have a main menu.
We have a load menu and we have a dungeon load menu is where I'd like to go.
Once I click on play.
So right here I'm going to call Open Level.
And we can open level by name.
We can open level by object reference to if we wanted to do that.
And then we could just promote this to a variable called load menu and compile and give this a default
value.
And we can choose load menu.
We could do that or we could load it by name.
Either way is fine.
A variable is pretty nice too.
Now we could rename these events.
We can say play button clicked.
And quit.
Button clicked.
Compile and save and now save all.
What I'm going to do is go into the load menu, and once we get into the load menu, we can start removing
things.
I'm going to remove aura.
As now.
We're not going to have any of that stuff if we press play.
We're just going to have just an empty level.
So we'll get to what happens in this level soon enough.
But for now, I'm going to save all and go back to main menu.
So we still have all this, but if we press play, we now have music buttons.
If we click quit, we quit.
And if we click on play now we go to this level.
And the load menu level doesn't have a whole lot, but we'll get to that soon enough.
For now, we have a working main menu, and I believe that is complete now, and we can even set this
to be the map that loads up when you start the game.
So if we go to Edit and project settings, we can go to Maps and modes and we can set our game default
map, we can set it to the main menu.
And when we do that, if we launch the game as a standalone game, we'll go to that level.
Okay.
Perfect.
So with that, we're done with the main menu.
We're ready to start on the load menu and we'll do that next.
I'll see you soon.