• 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 release event stopped working...

alandor

Member
My mouse release events on buttons has suddenly started behaving strangely. They only respond once every three or so clicks, sometimes more sometimes less. Does anyone have any idea what may be causing this? It's really annoying as I was setting aside time tonight to make progress on my game instead I have this really strange problem to solve.

In the same room as these buttons I also have a global mouse release event that gets called when those buttons are clicked. Could that be a cause for the buttons not responding to mouse clicks?
 

TheouAegis

Member
Well if you delete that event, or at least, comment it out and the error goes away, then you know that is what causes it. That would be a weird bug though. You aren't clearing the io or Mouse at all are you?
 

alandor

Member
No I'm not clearing the io or Mouse that I know of. That would be if one of the modules I'm using does it but I don't think so (for instance a menu I downloaded). Deleting the global mouse release event makes no difference to my problem so it is probably not related to that.
 

TheouAegis

Member
Is your room_speed or game speed set to 60 or higher? If you set it lower than that, input changes don't get detected properly.

Similarly, run the debugger and make sure fps and fps_real don't drop below 60.

If both of those check out, then go ahead and test If it is a bug with GM's events themselves. Comment out your Mouse Release events and instead put your code in the Step Event (or Begin Step event) using mouse_check_button_released() function. If the error goes away, it could have been a bug in GM.
 

alandor

Member
Thank you both for taking the time to answer. I noticed that the clickable area has been moved about a buttons width to the right of the button so that's the reason it doesn't work. I.e. if I click a bit to the right of the button it seems like it works (which is why I said it only works once in a while when I clicked around on the button only the ones to the far right registered - I should probably have realized this sooner). I don't know why it happens but it only happens in one particular room where I'm setting the camera to follow an object. In other rooms it works fine. I will be looking in to this tonight and see if I can figure it out, but I appreciate any feedback.

I don't know about masks but perhaps this problem could be related to it?
 

alandor

Member
The camera seems to be causing the issue but I don't know why. This code is in the camera step event and if I comment it out all buttons work as intended. But with that code all buttons are offset about 50 pixels to the right.

GML:
var _vm = matrix_build_lookat(x,camera_y,-10,x,camera_y,0,0,1,0);
camera_set_view_mat(camera,_vm);
The collision mask for these buttons is set to same as sprite so that is just what it should be right?
 

alandor

Member
I should maybe add that these buttons are drawn on GUI layer by having an empty draw event and a draw GUI event with only the draw_self() function. If I deactivate the draw GUI event and instead let the regular draw event draw the buttons I can see them moving around with the camera. And I understand that the clickable area of the buttons always move like this even when the Draw GUI event draws the buttons. Does this make sense? Do I need a function in addition to draw_self() in order to set the position of the clickable area? (Is this the same as collision mask?)
 

alandor

Member
Problem solved. I found this solution to use in the step event instead of mouse pressed event. I'm not sure about the parameter 0 in the device_mouse_x_to_gui function but it looks like it works.

GML:
if (mouse_check_button_pressed(mb_left)) {
    if (position_meeting(device_mouse_x_to_gui(0), device_mouse_y_to_gui(0), id)) {
        obj_controller.buttonClicked = true;
        BLPassButtonClicked();
    }
}
 
Last edited:
Top