Legacy GM Help with menus

D

Darky202

Guest
Hello everyone, I was wondering how could I create a horizontal menu with graphics (I mean, showing sprites instead of text) and how to add a sort of submenus for each option. I would really appreciate if you explain me how to do this since I'm completely lost and don't know what to do. Thanks for your help!
 
F

Freedom2Fight

Guest
There are tutorials out there you can view. However here are some stuff you may want to know.

If you want sprites intead of text use draw_sprite functions instead of draw_text functions.

You may want to create an object that handles your Menu. Something like obj_menu.

You might need to have code in your Step Event for handling which menu and or sub-menu is currently in.

For example: A variable called current_menu to keep track of... the current menu.
And code in the Draw Event (Draw Event or Draw GUI) that handles which sprites to be shown.

You should design your menu first before coding. Horizontal menu isn't much to go on.
 
D

Darky202

Guest
There are tutorials out there you can view. However here are some stuff you may want to know.

If you want sprites intead of text use draw_sprite functions instead of draw_text functions.

You may want to create an object that handles your Menu. Something like obj_menu.

You might need to have code in your Step Event for handling which menu and or sub-menu is currently in.

For example: A variable called current_menu to keep track of... the current menu.
And code in the Draw Event (Draw Event or Draw GUI) that handles which sprites to be shown.

You should design your menu first before coding. Horizontal menu isn't much to go on.
Ok, I understand your point but... I think I didn't explain properly what I wanted to do... Probably it's not exactly a menu such as the main menu but I was thinking about something like this:



(I know, the design is very poor... but this is most of it)
So... Well I watched some tutorials about menus but they are very confusing and don't really help me figure out what to do...
 
F

Freedom2Fight

Guest
I'm just going to use information from the image you've provided and I'm going to use keyboard inputs.

This is just something to get you started and may not be the best way.

First create an object that will handle the menu. Call it obj_menu or something.

Inside its create event, have a variable that will keep track of which option is selected. Lets call it selected_options for now. Set it to 0.

Then have another variable that will keep track of the sub-menus. Lets call it sub_menu. Set it to 0.

Then have another variable that will show the sub-menus. Call it show_submenu. Set it to false.

In the step event:

There are two options: A and B. Let option A be 0 and option B 1.

if keyboard_check_pressed (vk_right)
{ selected_options += 1; // increase selected_options variable by 1}
if keyboard_check_pressed (vk_left)
{selected_options -= 1; decrease selected_options variable by 1}

However you're going to have to keep selected_options from going over 1 and below 0. Because there are only two options A and B, represented by 0 and 1.

Write something to this effect. If selected_options is greater than or equal to 1 selected_options is equal to 1.

if selected_options >= 1 {selected_options = 1;}

Then do the same for going below zero.

Then lets work on getting the sub-menus to show.

if keyboard_check_pressed(vk_enter)
{ show_submenu = true;
if selected_options = 0
{ sub_menu = 0; }
if selected_options = 1
{ sub_menu = 1;}}

In the Draw event or Draw GUI event:

draw_sprite(sprite for Main Options, subimg (0), x coordinate, y coordinate);
draw_sprite(sprite for Main Options, subimg (1), x coordinate,y coordinate);

if show_submenu = true
{ if sub_menu = 0
{ draw_sprite(sprite for A option sub_menu, subimg, x , y);
draw_text(); //If you want text
then write something for sub_menu = 1}
 
D

Darky202

Guest
I'm just going to use information from the image you've provided and I'm going to use keyboard inputs.

This is just something to get you started and may not be the best way.

First create an object that will handle the menu. Call it obj_menu or something.

Inside its create event, have a variable that will keep track of which option is selected. Lets call it selected_options for now. Set it to 0.

Then have another variable that will keep track of the sub-menus. Lets call it sub_menu. Set it to 0.

Then have another variable that will show the sub-menus. Call it show_submenu. Set it to false.

In the step event:

There are two options: A and B. Let option A be 0 and option B 1.

if keyboard_check_pressed (vk_right)
{ selected_options += 1; // increase selected_options variable by 1}
if keyboard_check_pressed (vk_left)
{selected_options -= 1; decrease selected_options variable by 1}

However you're going to have to keep selected_options from going over 1 and below 0. Because there are only two options A and B, represented by 0 and 1.

Write something to this effect. If selected_options is greater than or equal to 1 selected_options is equal to 1.

if selected_options >= 1 {selected_options = 1;}

Then do the same for going below zero.

Then lets work on getting the sub-menus to show.

if keyboard_check_pressed(vk_enter)
{ show_submenu = true;
if selected_options = 0
{ sub_menu = 0; }
if selected_options = 1
{ sub_menu = 1;}}

In the Draw event or Draw GUI event:

draw_sprite(sprite for Main Options, subimg (0), x coordinate, y coordinate);
draw_sprite(sprite for Main Options, subimg (1), x coordinate,y coordinate);

if show_submenu = true
{ if sub_menu = 0
{ draw_sprite(sprite for A option sub_menu, subimg, x , y);
draw_text(); //If you want text
then write something for sub_menu = 1}
Thank you very much for this! This is really helpful, thanks a lot for your help :)
 
Top