GameMaker Problems with the Main menu

E

Explog

Guest
Hello everyone, it's me again.

Today I come with a problem that is most likely to be easy to solve, but I cannot find a solution, and unlike a few weeks ago today, I am going to put the problem.

The problem is that when changing the buttons in the main menu of my game, it does not visually change, but if you press space, the game executes the action to start the game.

By the way, before start reading, I warn you that it is a lot of code but that some parts can skip as they do not affect the problem, now start.

GML:
Information about object: objMenu

Sprite:

Solid: false

Visible: true

Depth: 0

Persistent: false

Parent:

Children:

Mask:





No Physics Object



Create Event:

execute code:



///Variables



//Titulo

title_name = "ExploGames";

title_angle = 0;

title_direction = "right"



menu = "principal";



button_num = 5;

button[1] = "Nuevo juego";

button[2] = "Cargar juego";

button[3] = "Logros";

button[4] = "Opciones";

button[5] = "Salir";



button_select = 1;



Step Event:

execute code:



///Titulo y botones



//Animación



if (title_direction = "right")

{

   title_angle -= 0.05;

   if (title_angle <= -5)

   {

      title_direction = "left";

   }

}

else if (title_direction = "left")

{

   title_angle += 0.05;

   if (title_angle >= 5)

   {

      title_direction = "right";

   }

}



//Subir y bajar botones

if (keyboard_check_pressed(vk_up))

{

   button_select -= 1;

   if (button_select = 0)

   {

      button_select = button_num;

   }

}

else if (keyboard_check_pressed(vk_down))

{

   button_select += 1;

   if (button_select = button_num + 1)

   {

      button_select = 1;

   }

}

//Acción que se va a realizar



if (keyboard_check_pressed(vk_space))

{

   switch(menu)

   {

      case "principal":

      {

         if button_select = 1

         {

            menu = "Mundos"

            button_select = 1

         }

          if button_select = 2

         {

            menu = "Cargar partida";

         }

         if button_select = 3

         {

            menu = "Logros";

         }

          if button_select = 4

         {

            menu = "Opciones";

         }

         if button_select = 5

         {

            game_end();

         }

      }break;

      case "Mundos":

      {

            button_num = 6;

            button[1] = "Mundo 1";

            button[2] = "Mundo 2";

            button[3] = "Mundo 3";

            button[4] = "Mundo 4";

            button[5] = "Mundo 5";

            button[6] = "Atras";

        

            if button_select = 1

            {

                room_goto(romLevel01);

            }

            if button_select = 2

            {

                menu = "Cargar partida";

            }

            if button_select = 3

            {

                menu = "Logros";

            }

            if button_select = 4

            {

                menu = "Opciones";

            }

            if button_select = 5

            {

        

            }

            if button_select = 6

            {

            room_goto(romPrincipal);

            }

            }break;

   }

}





Draw Event:

execute code:



///Dibujar Titulo



draw_set_font(fntTitle);

draw_set_valign(fa_center);

draw_set_halign(fa_center);



draw_set_colour(c_black);

draw_text_transformed(room_width/2 + 2, room_height/6, title_name, 1, 1, title_angle);

draw_text_transformed(room_width/2 - 2, room_height/6, title_name, 1, 1, title_angle);

draw_text_transformed(room_width/2, room_height/6 + 2, title_name, 1, 1, title_angle);

draw_text_transformed(room_width/2, room_height/6 - 2, title_name, 1, 1, title_angle);



draw_set_colour(c_white);

draw_text_transformed(room_width/2, room_height/6, title_name, 1, 1, title_angle);



execute code:



///Dibujar botones



draw_set_font(fntButtons);

draw_set_valign(fa_center);

draw_set_halign(fa_center);



for (i = 1; i <= button_num; i += 1)

{

   var height = (room_height/(3 + button_num)) * (2 + i);



   if (button_select = i)

   {

      draw_set_colour(c_black);

      draw_text_transformed(room_width/2 + 1, height, button, 1.2, 1.2, 0)

      draw_text_transformed(room_width/2 - 1, height, button, 1.2, 1.2, 0)

      draw_text_transformed(room_width/2, height + 1, button, 1.2, 1.2, 0)

      draw_text_transformed(room_width/2, height - 1, button, 1.2, 1.2, 0)

  

      draw_set_colour(c_yellow);

      draw_text_transformed(room_width/2, height, button, 1.2, 1.2, 0)

   }

   else

   {

      draw_set_colour(c_black);

      draw_text_transformed(room_width/2 + 1, height, button, 1, 1, 0)

      draw_text_transformed(room_width/2 - 1, height, button, 1, 1, 0)

      draw_text_transformed(room_width/2, height + 1, button, 1, 1, 0)

      draw_text_transformed(room_width/2, height - 1, button, 1, 1, 0)

  

      draw_set_colour(c_white);

      draw_text_transformed(room_width/2, height, button, 1, 1, 0)

   }

}
 

Nidoking

Member
button appears to be an array, but you appear to be trying to use it as a text string. Did you perhaps intend to draw one of the elements in the button array?
 
Top