(Redirected from Main Menu)

Document stub.png This article is a stub. It may be incomplete, unfinished, or have missing parts/sections. If the article can be expanded, please do so! There may be suggestions on its talk page. (June 2017)

Menus are selection screens often used to help navigate a project. They allow the viewer to select what to do, such as choosing a level or map in a game, enabling or disabling certain options, or managing certain tools. There are different types of menus, the most common being a main menu at the beginning of a game to formally introduce the player. Adding menus can professionalize a project since most applications and games outside of Scratch contain menus.

Types of Menus

An example of a start menu in a project.

Start Menu

A "start menu" usually refers to the main menu that appears at the start of a project. A start menu allows one to navigate through a project from a main "home" screen, often accessible by pressing the green flag again or some other method built into the project. Sometimes a start menu simply consists of a "start" button. They can be more complex with additional options to toggle sound, look at high scores, and more.

Pause Menu

A "pause menu" appears when one "pauses" or temporarily stops a project (not with the stop sign). In many projects, pause menus aren't necessary since no important progress will be missed if the end user leaves the computer. Pause menus may have different setting options on them, such as a volume slider, music being played, FPS, and so on. They don't often help with navigation but instead contain lots of settings.

An example of a sidebar in a project.

Sidebar

A sidebar is a type of menu commonly found inside of tutorial projects. Sidebars are usually found by hovering the mouse over the left or right side of the screen. From there, the sidebar will appear, often "sliding in" to the view. Sometimes there is a tab at the side of the screen that needs clicked for the sidebar to pan into view. Sidebars can help navigate different pages of tutorial or story projects; they may also have audio settings. Though, they can be used in any innovative matter in which a project creator deems a menu will assist the viewer in some way.

Making a Menu

Start Menu

Main article: Creating a Main Menu


Scripts in a project with a start menu will usually have the normal "when green flag clicked" block replaced with "when I receive [start v]" so that it starts when it is clicked in the start menu, rather than when the green flag is clicked. Instead, when the green flag is clicked, the start menu will appear and wait for the user to start it. You can program buttons that will start the game using the following code:

when this sprite clicked
broadcast [start v]
hide

when green flag clicked
show

With the above code, you'll be able to start the game by clicking the button. When you click the green flag, it'll appear again.

Pause Menu

One method of making a pause method is with a variable for whether the project is paused or not. A sprite or the backdrop will usually contain a script that sets the variable to paused if it isn't paused, or to paused if it is. This can be done with;

when [p v] key pressed//or any other pause button if <(paused?)=[true]> then set [paused? v] to [false] else set [paused? v] to [true] end

In other sprites running code, you should add this block to the code so it stops if it's paused.

... if <(paused?)=[false]> then ... end

Sidebar

To create a sidebar, you'll need to use the following code:

when gf clicked
forever
if <(mouse x) < [-220]> then
show
broadcast [show buttons v]
else
hide
broadcast [hide buttons v]
end

You can change the "<" to a ">" if you want to have the sidebar on the right, and edit the value to a positive number. Change the value if you want the sidebar to appear at different mouse positions than what is shown above. The buttons will appear and disappear based on the broadcasts received. Use the Start Menu tutorial to learn how to make buttons do different things.

See Also