Creating a Main Menu
A Main Menu is a menu, usually used in games, placed at the beginning of a project. It allows the user to decide to play the game, or use other features within the project, such as character customization. Main menus mostly consist of various buttons for accessing the different parts of a project. For this tutorial, it is assumed that the majority of the project's body is complete.
Basic Menu
Broadcasting is useful for main menus because it allows them to be easily pulled up multiple times in a project. It avoids the need to click the green flag to navigate back to the menu. The broadcast used in this tutorial is named open menu
In order to start, one will need to replace most "When Green Flag Clicked" script with "When I receive [open menu]" scripts, likely with exceptions. It's recommended to plan for this in advance, and not use "When Green Flag Clicked" hats for the main menu,
For example, one's original script might look like this:
But after the modification, it would look like this:
After this, make a separate backdrop for the title screen that includes the title and a new sprite named "Start Button". Inside this sprite, make two scripts:
The "Play" button is used for triggering the project to begin. Most often, when the button is clicked a message will be sent signaling the game to begin. The following script represents this:
Now when someone starts the project, it will show the menu instead of starting the game automatically.
Adding Title Music
Title music can be added to the game.
Make the following required Variable:
In any sprite, create a script like this one:
This script says that if the viewer is on the main menu, it will play the music.
Now, modify the Start Button script. Change it from this:
to this:
This prevents the title music from playing again, and then just stops it altogether.
External Links
- How to Make a Title Screen — A tutorial that teaches how to make a title screen.