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

HTML5 Why does resizing in a browser mess up my buttons?

M

Mobie

Guest
I thought I was getting to be OK at GML, but things keep coming up that make me feel like I haven't learned anything! Here's my latest conundrum:

I have been reading the GM tech blogs about resizing a canvas to fit browser windows and can make things resize just fine, but it seems like the clickable areas of my button objects don't resize with the window. If I make the browser window smaller, I find that the clickable areas of my buttons are located nowhere near where the button draws. You have to move the mouse quite a bit away from the object to trigger the "Mouse Enter" sprite change, and click in that area away from the button to operate the button. This only happens when I output to HTML5; everything works fine when I set it to Windows. What am I doing wrong? I'm wondering if it has something to do with not using Draw GUI events, but I'm still not grasping that concept, what it is I'm doing wrong, or how to fix it.

Thanks for your help, and thanks even more for you patience with these dumb questions! -Mobie
 
Last edited by a moderator:
M

Mobie

Guest
For anyone else that might have that trouble, I found the problem. I went into the HTML5 settings in GM and disabled WebGL. I know that's a graphics rendering thing, and that's all I know about it, but it was apparently messing up my scaling.
 

Amon

Member
I think a different solution would be better than disabling webgl. Isn't webgl what html5 uses for the canvas graphics?
 
M

Mobie

Guest
I think a different solution would be better than disabling webgl. Isn't webgl what html5 uses for the canvas graphics?
Could be, I'm just a hack at this. But it worked so far. If you know of something else, please share.
 
M

Mobie

Guest
I think a different solution would be better than disabling webgl. Isn't webgl what html5 uses for the canvas graphics?
It turns our you were right. With Web GL turned off, the game would work about 10 seconds on my iPhone and then crash. Oh well, back to the drawing board.
 

Amon

Member
Try drawing your buttons using the sprite in the drawGUI event, use draw_sprite_ext I think, then, use point in rectangle to check if the mouse is within the button sprites bounds. That's what I do and it works perfectly.
 
M

Mobie

Guest
Try drawing your buttons using the sprite in the drawGUI event, use draw_sprite_ext I think, then, use point in rectangle to check if the mouse is within the button sprites bounds. That's what I do and it works perfectly.
That sounds like the right fix! I'll work on that for a day or two. Thanks so much, Amon!
 
Top