ThatGuyMiniB Posted June 3, 2017 Share Posted June 3, 2017 I have been having problems when I scale my gamemaker 2 html5 game to fit the height of the browser. Once it scales up it no longer detects the mouse position. Without it being scaled to height I am able to click on my enemies, but when it is scaled to browser height I am unable to. I figure it has to do with the scaling to the browser height Thanks in advance! if(os_type == os_windows){ ideal_width = 0; ideal_height = browser_height; start_b_width = browser_width; start_b_height = browser_height; aspect_ratio = browser_width/ browser_height; ideal_width = round(ideal_height / aspect_ratio); if(ideal_width & 1){ ideal_width++; } room_set_width(rm_game, ideal_width); room_set_height(rm_game, ideal_height); surface_resize(application_surface, ideal_width,ideal_height); room_goto_next(); alarm[0] = 60; } //In my alarm window_set_size(room_width,room_height); window_center(); Quote Link to comment Share on other sites More sharing options...
kaasis Posted June 3, 2017 Share Posted June 3, 2017 I'm pretty sure, you should ask this into GameMaker's community forum not here. Quote Link to comment Share on other sites More sharing options...
ThatGuyMiniB Posted June 5, 2017 Author Share Posted June 5, 2017 I have asked it there but no one replied :/ Quote Link to comment Share on other sites More sharing options...
IndieDevBateman Posted June 5, 2017 Share Posted June 5, 2017 Recommend you do some debugging. Run your engine and draw values to screen and see what they say. E.g. store your mouse_x, mouse_y values to variables on mouse pressed and draw them to screen, plus the various display var you are using. See what's happening. I suspect on changing your window size you are altering your collision mask locations and so when you click, you are not hitting the masks, but debugging should help you to understand what's happening and then you can work a way to resolve it. Quote Link to comment Share on other sites More sharing options...
ThatGuyMiniB Posted June 5, 2017 Author Share Posted June 5, 2017 I have done some debugging and what I found was that the mouse coordinates are off from the actual mouse. I made a sprite that would follow mouse_x and mouse_y for my object that registered mouse clicks and it was just way off from the actual mouse, but when the sprite was at the location of and object it can click and destroy it did just that. I have tried to figure out how to fix this offset but I have had no luck so far. Quote Link to comment Share on other sites More sharing options...
IndieDevBateman Posted June 5, 2017 Share Posted June 5, 2017 Yeah you're offsetting due to your scale engine. You just need to alter your registered mouse x and y by the same scaling you're applying to your surface/window. So instead of straight collision checking mouse x mouse y, you'll need to be checking something like mouse x(y) / aspect ratio. Something like that anyway. Without playing with the code I can't quite work it out in my head, but if you use your debug coordinates of what it is reading as x and y and what you expect it to read, you should be able to suss the alteration required. You can sort of see what I mean in a test engine I made recently here: http://michael-bateman.com/games/B5/ See how the actual mouse x/y are converted to match the alteration due to scaling. This is most obvious on a mobile device. Quote Link to comment Share on other sites More sharing options...
ThatGuyMiniB Posted June 7, 2017 Author Share Posted June 7, 2017 Thanks! I will do this and see if I can fix it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.