F
instance_create_depth (room_width/2,160,1,obj_menu);
instance_create_depth (room_width/2 + 40,160,1,obj_first_tower);
//Left Pressed
global.tower = towerOfSecrets; //selects your tower choice and stores it in a global variable
image_index = 3; //highlights the button
//Mouse Enter
image_index = 2; //50 percent lighter in shade
//Mouse Leave
if (image_index != 3)
{
image_index = 1; //sets back the tower 'button' to normal once the mouse leaves
}
instance_destroy(obj_menu);
instance_create_depth(0,0,1,obj_towers_menu);
// Here you create how much towers you want
array[0] = "Tower\n1";
array[1] = "Tower\n2";
array[2] = "Tower\n3";
array[3] = "Tower\n4";
// Buttons position
var _xx = display_get_gui_width()/2;
var _yy = 160;
var _spacing = 70;
// Loop the buttons and draw it
for (var i = 0; i < array_length(array); i+=1)
{
// draw back button
draw_rectangle_color(_xx+i*_spacing, _yy, _xx+i*_spacing + 50, _yy + 50, 0,0,0,0,false);
// draw tower text
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(25+_xx+i*_spacing, 25+_yy ,array[i]);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
// draw mouse select color
if point_in_rectangle(device_mouse_x_to_gui(0), device_mouse_y_to_gui(0), _xx+i*_spacing, _yy, _xx+i*_spacing + 50, _yy + 50)
{
// white outline button rectangle
draw_rectangle_color(_xx+i*_spacing, _yy, _xx+i*_spacing + 50, _yy + 50, c_white,c_white,c_white,c_white, true);
// mouse press action
if mouse_check_button_pressed(mb_left)
{
switch (array[i])
{
case array[0]:
show_message("Tower 1 Created.");
break;
case array[1]:
show_message("Tower 2 Created.");
break;
case array[2]:
show_message("Tower 3 Created.");
break;
case array[3]:
show_message("Tower 4 Created.");
break;
}
}
}
}
show_message ("Tower X Created.")
Is;