Legacy GM Keeping sprite from disappearing after "check pressed" event ends



I'm trying to build a menu where when a user selects an option, a sub menu appears to the right of the first set of options. Attached is a picture of what I have so far.

The problem I'm having right now is that when use the following code to draw the next section of the menu -

case 0:

(which leads to the drawParty script that simply does the following)


When I select the first option (party) the sprite I want to appear only does so for a second after the keyboard check I have finishes and then promptly disappears.

globalvar push;
push = max(keyboard_check_pressed(vk_enter),0);

I've also tried using keyboard_pressed which made the sprite appear only for as long as enter was pressed. I also tried adding some logic that said while some variable was true, draw the sprite which also didn't work. I also tried making an if statement that said if(keyboard_check_pressed(vk_enter)) draw the sprite, and that didn't work correctly either.

What's the correct method for drawing a sprite and making sure it doesn't disappear after it's key check ends?




You were on the right track with the variable method. When the keyboard is pressed, you can set a variable to true. In the draw event, check that this variable is true and if it is, draw. The only thing I'm not sure about is what turns the variable to false. Since I don't fully understand what you're aiming for, I'm afraid I can't help you there. But I hope I answered your problem satisfactorily :confused:


whats the point of using max(keyboard_check_pressed(vk_enter),0);
it should return 1 or 0 anyways...

now let me explain a little about the draw event.
the draw event is similar to the steps even as it is run at the end of each "game step" and draw functions in the draw event are not persistent.
This means that if you drew a sprite in the step where you pressed enter, it will be drawn in that step. but it wont be drawn in the next step unless you press enter again.
this is why when using keyboard_check_pressed the sprite was being drawn until you released the enter key as that function returns true as long as you are holding the button.

now what i suggest is for you to make a variable called DrawSprite and initialise it to 0;
then in the step event, run:
 if keyboard_check_press(vk_enter)
     DrawSprite = 1;
then put this in the draw event:
if DrawSprite
    //draw your sprite here