# Import the necessary Verse libraries
using { Core }
using { CoreGame }
using { Ui } # Ui library handles UI elements like widgets
# Define our custom menu struct.
# Think of this as the "Character Sheet" for our menu.
struct TacticalMenu: Ui::Widget:
# This is our "Player" variable for the menu.
# It holds the reference to the Popup Dialog device in the level.
PopupDevice: Ui::PopupDialog = Ui::PopupDialog{}
# Function to OPEN the menu.
# Analogy: Like opening your inventory screen.
func OpenMenu() -> void:
# We tell the PopupDialog to show our Widget.
# It's like saying "Show the map!"
PopupDevice.SetWidget(Self)
PopupDevice.SetVisibility(Ui::Visibility::Visible)
# Optional: Pause the game loop here if you want time to stop.
# CoreGame.GetWorld().PauseGame(true)
# Function to CLOSE the menu.
# Analogy: Like closing your inventory to shoot.
func CloseMenu() -> void:
PopupDevice.SetVisibility(Ui::Visibility::Hidden)
# CoreGame.GetWorld().PauseGame(false)
# This is an EVENT. It runs when the "Resume" button is clicked.
Verse Library
verse
01 Fragment
Creates a custom UI widget that handles opening, closing, and button events for a functional game pause menu.
verse-library/4-creating-the-game-menu/01-fragment.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.