• 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!

GameMaker Mouse-Event Ordering or Not

M

minoush82

Guest
Hello,

In my application (some sort of quiz), the user clicks a button and this triggers a score update inside the Left Pressed event of the button object. The Left Pressed event also does some other processing including displaying a feedback message for a couple of seconds. After that, the room restarts (to ask the next quiz question).

The problem I am facing is that when the user repeatedly and quickly clicks the button within 2 seconds, say 5 times, the score gets updated 5 times which is the wrong behaviour. I would like the first mouse click to trigger the score update, and the subsequent mouse clicks on the button to be ignored.

I was thinking that the Left Pressed mouse event needs to finish executing before a new one can start running. In my case, I thought that subsequent mouse clicks that occur while the first mouse click is still displaying the feedback message will get ignored since the first one has not finished executing.

So, are Left Pressed mouse events serviced as they come without the need for them to wait for previous ones to finish processing? If yes, what is a good way to solve my problem?

My solution so far has been to define a boolean guard in the Create event and set it to true. Then, I would check for this guard before processing the score in the Left Pressed event; and set it to false after the score has been updated. Subsequent mouse clicks will not trigger score update which is guarded by the boolean (now set to false). But I feel this is more of a hack, and would like a better solution is possible.

Many thanks,
Amine.
 
J

J_Dev

Guest
No, using a boolean is not a hacky method. It's perfect for this situation.
 
Top