Usage¶
Setup guide¶
This will guide you through the important steps to set up a fully functional menu.
Regions¶
Open oMenu
’s create event, here is everything for configuring the menu.
Here you’ll see a lot of regions. All of them are marked either with a (system) or a (user) tag. You only want to change the (user) tagged regions.
Every region is a settings for something.
- Here is a list of the regions and what they do:
Audio settings - Menu sound effects settings
Credits text - Text for credits (if you have one)
Look settings - The menu’s look, visual settings
Animation settings - Button animation settings
Scrolling settings - Settings for scrolling (if you have a big menu page)
Pause settings - Pause menu settings
Menu array - The menu’s structure (buttons and what they do)
Input setup - Menu navigation settings
Changing the look¶
To change the way your menu looks go into the Look settings region.
- Here you will see two structs:
look
- The look settings of the entire menuitem_look
- The look of individual items (e.g. sliders, toggles, shifts, etc.)
There are a bazillion options so I won’t go through all of them but here are the imporant ones.
Start with the look
struct.
- Here are are the three main settings.
txt
- Text font, size, outline etc.col
- Color settingspos
- Position of the menu and elements
In the text settings there is a normal and small text type. Normal is used most of the time, small is for input icons and disclaimer text at the bottom.
Set your own fonts for both if you don’t like the default one.
Note
There are options marked with an (A) tag. These can be set to
auto
(automatic). If so the system will predict an appropriate size for the item. If the systems prediction is wrong just try until you find a good-looking value for it.
Then go onto the col
struct. Here are two types selected and unselected. You have to set two colors each, one used most of the time and a more intense/dark color.
Set them to your liking.
Then in the pos
struct, you most likely want to change the menu_pos.y
because the menu is in the middle by default so it may cover the title of your game or something.
You can set a nine slice sprite four your buttons background, to set it go to item_look
> button
and set the nine_slice
variable to a sprite that is nine slice enabled.
- But in case someting isn’t working how you want it. Here are the other things I didn’t talk about:
If a specific menu element looks wrong find it in Look settings >
item_look
structTo change the menu’s sounds go to Audio settings
To change the button animation or turn it off go to Animation settings
To change scrolling behaviour go to Scrolling settings
To change things about pausing go to Pause settings
To change buttons used to navigate the menu go to Input setup
And here are some tips if your font looks odd.
If you are using a pixelated font turn of anti-aliasing on it. And if it still doesn’t look right try changing the size of the asset until it looks good, the nuber should be around the height of the font in pixels.
On the other hand you are using a non-pixelated font scaling will mess it up, so go into look > txt and set scale to 1
.
Now you will have to change the font assets size until it is properly sized, it takes some time but it’s worth it.
Pausing¶
If have a game with a title menu you usally want to have a pause menu as well. For that the system offers a built in pause system wich will basically take a “photo” of the screen, deactivate every object, and than draw the “photo” on the screen. This way it looks that the game is paused.
- You can do this two ways:
Manually - by calling the
pauseGame()
andresumeGame()
functionsAutomatically - by calling the
menuPauseEnable()
, and from then the menu will handle pausing
You also have to disable the menu when you enable pausing, because it would cover half of your game. But you want to reenable it when you go back to the title screen.
- For this purpose I made two useful scripts.
menuModeTitle()
enables the menu and disables pausing, because you don’t want the player to pause the game when it isn’t started yet.menuModePause()
disables the menu so that you can see the game, and enables pausing so that you can use the pause menu.
And also when you enable pausing you most likely want the menu to look a bit differently, for instance replacing a start button start with resume. If you haven’t made any menu presets read about them here.
Ok, so when you want to switch to pause mode call the menuModePause()
function and set your preset by calling menuSetPreset()
.
And when you want to set it back to title screen mode call menuModeTitle()
and set you preset back with menuSetPreset()
.
Here is an example of a Start button with a Resume preset.
["Start", new ScriptRunner(function() { menuModePause(); menuSetPreset(e_menu_presets.pause_menu); room_goto(rGame); }), "Resume", new ScriptRunner(resumeGame)]
And here is an example of a Quit button with a Back to title preset.
["Quit", new ScriptRunner(game_end), "Title Screen", new ScriptRunner(function() { menuModeTitle(); menuSetPreset(e_menu_presets.title_screen); room = rTitle; })]
To see a fully set up menu example with pausing, click here.
To change how the menu looks when the game is paused go to the Pause settings region in the create event.
The settings struct (getting values)¶
After you have created your menu you want to get the values of settings somehow.
The values are stored in a struct called global.settings
.
To get the value of an item write global.settings.save_key
where the save_key
is the string what you defined in the menu array when you created the item.
- Here is how the different elements save their values:
Slider
- (type: real) The value will be in the range you defined when you created itShift
- (type: real) The value will range from0
to thenumber of options - 1
Toggle
- (type: bool) Eithertrue
orfalse
Controls
- The controls changes the given input system directly it does not return anything
You can do anyting with these values in any object but there is a Change actual values region in the menu’s step event for it. Here you can change the window size, volume etc.
Here is a basic example:
audio_master_gain(global.settings.audio_master); if (global.settings.window_mode != window_get_fullscreen()) window_set_fullscreen(global.settings.window_mode);