Menus

In this mini-guide, we’ll make add a menu to our game, using Godot’s User Interface (UI) facilities.

Let’s get started.

Adjust Title

Center Top

Adjust StartButton

Example

This is roughly what it could look like now.

WIP

Hooking up the Start button

extends Button

# Makes a file selector available in the Inspector, and
# stores the path of the selected file in the variable "scene".
@export_file("*.tscn") var scene

# When the user presses the button of the script
func _on_pressed():
	# Change to the selected scene
	get_tree().change_scene_to_file(scene)

You may notice that this This is very similar to what we did for flag portals earlier! Just simpler.

Scene Select

Set as Main Scene

That’s it. You have a main menu.

Bonus: More buttons

You can duplicate StartButton if you want other buttons that load other levels - or even different menus.

Imagine a menu that has an overview of all the available levels.

Or a settings menu.

Or a shop menu.

You get the idea… Have fun!

Example