

Scaled_left, scaled_top, scaled_right, scaled_bottom))

If (point_in_rectangle(scaled_mouse_x, scaled_mouse_y, Var scaled_bottom = bottom * scale_ratio_y Var scaled_right = right * scale_ratio_x Var scale_ratio_x = scaled_mouse_x / mouse_x Var scale_ratio_y = scaled_mouse_y / mouse_y Var scaled_mouse_y = obj_canvas_scaler.scaled_mouse_y After putting in some debug messages I noticed the button's x, y, sprite_width and sprite_height were not changing when the canvas was being resized, so I tried to scale them the same way I scaled the mouse_x and mouse_y by doing this: var scaled_mouse_x = obj_canvas_scaler.scaled_mouse_x This is the only solution I have have found to this issue to date. You can set the trails to short so that they are not as annoying. I'm trying to use point_in_rectangle to see if the mouse is inside the button because I noticed the button's collision mask wasn't being scaled with the object so I'm trying to avoid using the mask. For the mouse position part of this problem, if you turn on 'Mouse Trails' in the windows mouse settings, this will fix the offset issue. That was a good catch, though moving those lines outside of the if block didn't seem to change anything. (surface_get_height(application_surface) / base_height) Īny and all suggestions/help would be greatly appreciated, and I can provide more details/code if needed. (surface_get_width(application_surface) / base_width) Scale_canvas(base_width, base_height, width, height, Height = min(base_height, browser_height)
#Phonegap android mouse coordinates wrong code#
Here is the code I used for the step function of my canvas scaler object: if (browser_width != width || browser_height != height) I think I need to do something with regards to the application surface. I have looked everywhere online for a solution, and have tried a few things like using the new width and height of the surface with surface_get_width and surface_get_height after the resizing occurs, using window_view_mouse_get_x with the application surface, and using device_mouse_raw_x (this only works after the player presses the mouse button, though). I've been testing it out with the play button on the main menu and the button changes sprites when the mouse hovers over it, but this is happening when the mouse is at the wrong place. The resizing works just fine, but the problem is the mouse coordinates are being read incorrectly after the game is resized.
#Phonegap android mouse coordinates wrong how to#
I am working on a browser game in Game Maker: Studio 2, and I used this blog post to learn how to resize the game canvas when the player resizes the browser window:
