3
\$\begingroup\$

I Have a button that starts in a rest state, and then after clicking on the button, it animates out. I want to disable the mouse click for around 30 steps after the button has been clicked, otherwise the player will be able to constantly click on the button, which resets the animation and messes up my menu.

Is there any way to disable the mouse click for a duration of time before enabling it again?

This is the code I have used to try and make the variable "click" alternate between true and false (it is supposed to remain false while alarm[0] is between 30 and 0).

Initially (in the create event)

click = false;
alarm[0] = -1;
alarmReset = true;

this is the code found in the step event:

if(mouse_check_button_pressed(mb_left))
{
    if(alarmReset == true)
    {
    click = true;
    alarm[0] = 30;
    alarmReset = false;
    }
} 

if (alarm[0] > 0 )
{
    if (alarm[0] < 30)  click = false;
}
if (alarm[0] < 0 ) alarmReset = true;

When running this code, "click" is initially false, but when I click, it gets set to true, and then is never set to false again. Any help would be appreciated.

\$\endgroup\$
2
\$\begingroup\$

I would do this

if(mouse_check_button_pressed(mb_left) && click)
{
    click = false;
    alarm[0] = 30;
}

Then in your alarm[0] event say

click = true;

That way you don't have to check on what state the alarm is in all the time.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.