1. สร้าง font ขึ้นมา 1 ขนาด 30 หรือตามใจชอบ
2. สร้าง obj_menu เพิ่ม event ดังนี้
2.1 add event create
Code:
_index=0;
menu[0]="START";
menu[1]="LOAD";
menu[2]="ABOUT";
2.2 add event step
Code:
if keyboard_check_pressed(vk_up) {
if _index <= 0 {
_index=array_length_1d(menu)-1;
}else{
_index--;
}
}
if keyboard_check_pressed(vk_down)
{
if _index >= array_length_1d(menu)-1 {
_index=0;
}else{
_index++
}
}
if keyboard_check_pressed(vk_enter)
{
if _index == 0 {
//Stat game
show_message("start game");
}
if _index == 1 {
//Load
show_message("Load game");
}
if _index == 2 {
//about
show_message("about game");
}
}
2.3 add draw
Code:
draw_set_font(fnt_default);
var xx = x;
var yy = y;
var color = c_black;
for(var i =0 ; i < array_length_1d(menu);i++){
color = c_black
if _index == i color = c_red;
draw_set_color(color);
xx=(room_width/2)-string_width(menu[i])/2;
yy=(room_height/2)-(string_height('A')*(array_length_1d(menu)-1))/2;
draw_text(xx,yy+(i*string_height('A')),string(menu[i]));
}