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

Mouse button checking is inconsistent/unresponsive.

Endzerhi

Member
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))
room_goto_next();
//Library
if (mouse_y > 750) && (mouse_y < 800) && (mouse_check_button_released(mb_left))
room_goto(rm_artists);
//Options
if (mouse_y > 800) && (mouse_y < 850) && (mouse_check_button_released(mb_left))
global.options_open = true;
//Credits
if (mouse_y > 850) && (mouse_y < 900) && (mouse_check_button_released(mb_left))
room_goto(rm_credits);
//Quit game
if (mouse_y > 900) && (mouse_y < 950) && (mouse_check_button_released(mb_left))
game_end();
};

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.
 

Niften

Member
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.
 

Endzerhi

Member
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.
 
Top