C
CRob1974
Guest
Hi,
I have been trying to create a text menu in GM2 and I now understand the following tutorial:
I would now very much like to create sub menus / links. For example: Options would lead to Display, Sound & Controls. At the moment it just shows a show_debug_message
Is there any way of doing it using 1 Control Object & 1 Room?
I have achieved this by transitioning with room_goto() and creating a new obj_control (placed in a new room) but this seems very long winded.
Thank you
PS. I dont expect you to watch the whole video, so here is the code from Code Workshop (not my code)
I have been trying to create a text menu in GM2 and I now understand the following tutorial:
I would now very much like to create sub menus / links. For example: Options would lead to Display, Sound & Controls. At the moment it just shows a show_debug_message
Is there any way of doing it using 1 Control Object & 1 Room?
I have achieved this by transitioning with room_goto() and creating a new obj_control (placed in a new room) but this seems very long winded.
Thank you
PS. I dont expect you to watch the whole video, so here is the code from Code Workshop (not my code)
Code:
//Create
menu_x = x;
menu_y = y;
button_h = 32;
button[0] = "New Game";
button[1] = "Load Game";
button[2] = "Options";
button[3] = "Exit";
buttons = array_length_1d(button);
menu_index = 0;
last_selected = 0;
//Step
menu_move = keyboard_check_pressed(vk_down) - keyboard_check_pressed(vk_up);
menu_index += menu_move;
if (menu_index < 0) menu_index = buttons - 1;
if (menu_index > buttons - 1) menu_index = 0;
if (menu_index != last_selected) audio_play_sound(snd_menu_switch, 1, false);
last_selected = menu_index;
//Draw
var i = 0;
draw_set_font(font_main);
draw_set_halign(fa_center);
draw_set_color(c_ltgray);
repeat(buttons) {
draw_set_color(c_ltgray);
if (menu_index == i) draw_set_color(c_red);
draw_text(menu_x, menu_y + button_h * i, button[i]);
i++;
}
//Key Press Enter
switch(menu_index) {
case 0:
show_debug_message("NEW MENU");
break;
case 3:
game_end();
break;
}
Last edited by a moderator: