• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ Mouse button checking is inconsistent/unresponsive.


I just recently converted a Gamemaker 1.4 project to Gamemaker 2, and I've noticed that the game tends to dip in frames when loading new textures for the first time. In addition to this, mouse_check_button_released functions in my main menu room have stopped working consistently. When clicked, they are supposed to change the room. What's weird is sometimes they work, and sometimes they don't. I use rather large animated sprites for background images on these menus. Could there be some kind of slow down caused by texture pages that causes the mouse functions to stop working? How can I sort out my texture pages to better optimize this sort of project?

if (mouse_x > 1548) && (!global.options_open)
//Play game
if (mouse_y > 700) && (mouse_y < 750) && (mouse_check_button_released(mb_left))
if (mouse_y > 750) && (mouse_y < 800) && (mouse_check_button_released(mb_left))
if (mouse_y > 800) && (mouse_y < 850) && (mouse_check_button_released(mb_left))
global.options_open = true;
if (mouse_y > 850) && (mouse_y < 900) && (mouse_check_button_released(mb_left))
//Quit game
if (mouse_y > 900) && (mouse_y < 950) && (mouse_check_button_released(mb_left))

An additional draw event that I use to draw and highlight the menu options in these same locations confirms that the mouse coordinates are correct when I'm checking for the click. Also, after one of the menu buttons works, that button begins working consistently until I try clicking a different one.


Try drawing some text to show mouse_x and mouse_y and make sure those conditions are being met. Another note: it would be more efficient to move the (mouse_check_button_released) conditional in front of the other conditions. Better yet, you could wrap all of your mouse position checks in one call of (mouse_check_button_released).

As for your question about texture pages - what's causing the slowdown are texture swaps. If you run your game in debug mode, you will be able to see the number of texture swaps happening. Essentially, texture swaps are the game switching from one texture page to another - to avoid this, you could have your background images on the same texture page, but as you said, they are large, animated sprites.

Here are some questions I have for you:
  • How large are these sprites?
  • How many frames do they have
  • How large are your texture pages currently?
Hope this helps.


I'm going to try cutting my sprites down and lowering my game speed, it looks like there's a lot of texture swaps because of how large the images are (960x540 60fps). Thanks for the help, I just need to take some time to optimize my images.