• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Two instances of a Menu. (Repeating Menu)

Hi everyone,

I'm trying to make a simple menu. It is the unlock menu for getting access to the bat you click on. Maybe this is easier to post in code:

BatsFaceBHiddenB: Step

GML:
if mouse_check_button(mb_left)
{
    //turn on menu
   if position_meeting(mouse_x, mouse_y, BatsFaceHiddenB)
   {
    //below doesn't execute
    show_debug_message("position meeting")
    //below doesn't execute
    
    show_debug_message("mouse check button")
    
    //Player.hasbatB = true;
    hasbatB = false
    query_batB = true;
   }

  //Unlock prompt? Below
 
    //clicked yes
     if mouse_check_button(mb_left)
     {
         //below yes clicked
        if (mouse_x > 304 && mouse_y > 637 && mouse_x < 477 & mouse_y < 717 && query_batB)
        {
            //Yes selected
            show_debug_message("query bat yes selected"); //successful
             //replace bat face to unlocked version
            global.select_bat = 2; //the bat to drop
            
            Player.hasbatB = true;
            query_batB = false;
            instance_create_depth(x, y, -1900, BatsFaceB)
            instance_destroy()
        
        }
 
        else if (mouse_x > 304 && mouse_y > 746 && mouse_x < 477 && mouse_y < 809 && query_batB)
        {
            show_debug_message("query bat no selected")
            query_batB = false;
        }
    }

 
 
}

BatsFaceBHiddenB: Draw

Code:
draw_self()

//show_debug_message("Draw Self test")




  

draw_set_font(SmallChancery)
if (query_batB == true && Player.hasbatB != true)
{
    
    draw_text_ext_transformed_colour(350, 550, "Unlock this bat?", 5, 300, 1, 1, 0, c_red, c_red, c_red, c_red, 1)
    draw_text_ext_transformed_colour(350, 650, "Yes?", 5, 300, 1, 1, 0, c_red, c_red, c_red, c_red, 1)
    draw_text_ext_transformed_colour(350, 750, "No!", 5, 300, 1, 1, 0, c_red, c_red, c_red, c_red, 1)
    //draw_text_ext_transformed_colour(550, 650, "50", 5, 300, 1, 1, 0, c_red, c_red, c_red, c_red, 1)
    draw_text_transformed_colour(550, 650, "50", 1, 1, 0, c_white, c_white, c_white, c_white, 1);
    
    
    //if (!instance_exists(GemPack1))
    //{
//        instance_create_depth(450, 650,-2000, GemPack1)
//    }
}
So, the above. That set of draw commands displays the menu. So I tried adding the draw_text_transformed_colour(550, 650, "50", 1, 1, 0, c_white, c_white, c_white, c_white, 1);
so it is like above. So, the "50" doesn't show up. I deleted the first line as a test and when I run that with the malformed "Unlock" and there was no effect. So it must be somewhere else
in the code since changing the block of code doesn't change anything. So I thought to myself, maybe I have two copies of that code block. So I did a search for "Unlock" in the code and
only one showed up in the results. So where is this phantom menu? Ideas?
 

Xer0botXer0

Senpai
These conditions must be met for your text to appear.

if (query_batB == true && Player.hasbatB != true)


This click event causes the first condition to be true,

if mouse_check_button(mb_left)
{
if position_meeting(mouse_x, mouse_y, BatsFaceHiddenB)
{
//Player.hasbatB = true;
hasbatB = false
query_batB = true;
}
}

no where in your posted code is Player.hasbatB set to false.

Did you declare hasbatB in your players create event and set it to false ?

Also, did you create BatsFaceHiddenB ? else position_meeting wont run, besides the obvious you need to left click and your mouse_x/y coordinates need to be at the instances origin, further more if the instance doesn't have a sprite or mask then it won't work either.
 
Last edited:
@Xer0botXer0

As for hasbatB it is set in my Player object which is just a controller for the bats. I changed the yes, no, and unlock from draw_text to actual objects that I can check against. This is the new version. Thanks. :)

GML:
draw_self()


//print menu
show_debug_message("Draw Self test")



   


//draw_text_ext_transformed_color(600, 600, "Mouse X " + string(mouse_x), 5, 300, 4, 4, 0, c_red, c_red, c_red, c_red, 1)
//draw_text_ext_transformed_color(600, 700, "Mouse Y " + string(mouse_y), 5, 300, 4, 4, 0, c_red, c_red, c_red, c_red, 1)

//Displays the unlock hidden bats routine

draw_set_font(SmallChancery)
if (mouse_check_button_released(mb_left))
{
    show_debug_message("querybatB prior")
    if (query_batB == true)
    {
   
   
        if (!instance_exists(a_unlock))
        {
            show_debug_message("instance a unlock")
            a_unlock = instance_create_depth(350, 550, -1200, question_unlock)
        }
        if (!instance_exists(a_yes))
        {
            show_debug_message("instance yes unlock")
            a_yes = instance_create_depth(350, 650, -1200, question_yes)
               
            new_gems = global.gems - 50
       
            if (new_gems > 0)
            {
                global.gems -= 50
               
                global.select_bat = 2; //the bat to drop
               
               
                Player.hasbatB = true;
                query_batB = false;
                instance_create_depth(x, y, -1900, BatsFaceB)
                instance_destroy()
                draw_sprite(GemPack1, image_index, x+210, y+600);
            }
        }
           
       
        if (!instance_exists(a_no))
        {
            show_debug_message("Instance a no exists");
            a_no = instance_create_depth(350, 750, -1200, question_no)
            query_batB = false
        }
        if (last_menu_timer <= 0)
        {
            draw_text_color(350, 650, "Not enough gems", c_black, c_black, c_black, c_black, 1)
            last_menu_timer = room_speed
       
       
        }
       
        show_debug_message("Pre draw text 50");

        //Not drawing
        draw_text_transformed_colour(500, 500, "50", 5, 5, 0, c_black, c_black, c_black, c_black, 1);
   
        //show_debug_message("Gem Pack sprite")
        //doesn't draw the gem
        draw_sprite(GemPack1, image_index, x+210, y+600);
        //print menu
    }
}



if mouse_check_button_released(mb_left)
{
    //not necessary
    //instance_position(mouse_x, mouse_y, question_unlock)

   
    //if instance position  finds a result
    inst2 = instance_position(mouse_x, mouse_y, question_yes)
    if (inst2 == true)
    {
        show_debug_message("instance query bat yes selected"); //successful
           
        new_gems = global.gems - 50
        if (new_gems > 0)
        {
            global.gems -= 50
               
            global.select_bat = 2; //the bat to drop
        }      
               
        Player.hasbatB = true;
        query_batB = false;
        instance_create_depth(x, y, -1900, BatsFaceB)
        instance_destroy()
        draw_sprite(GemPack1, image_index, x+210, y+600);
    }
       
    else
    {
        query_batB = false
        if (last_menu_timer <= 0)
        {
            draw_text_color(350, 650, "Not enough gems", c_black, c_black, c_black, c_black, 1)
            last_menu_timer = room_speed
       
        }
    }
       
    instance_destroy()  
}
   
else
{
    show_debug_message("query bat no selected")
    query_batB = false;
}

//question no answer

inst3 = instance_position(mouse_x, mouse_y, question_no)
if (inst3 == false)
{
    instance_destroy(question_no)
}
So in words, what happens is this. I click on the HiddenBatFace on the Bat Bar. That brings up the the unlock menu, with choice yes or no to unlock the bat. If you choose yes it checks the number of gems available. If there isn't enough gems available it gives an error message and quits. If there is enough gems it subtracts the gems from the player and and unlocks the bat. Now the player can click on that bat face and it will spawn that bat. I hope that clears things up
 
Last edited:
Top