Right. Where to begin?
I think what I want is fairly simple: to draw to my GUI layer and have that layer remain in the same place while allowing the player to resize the window or the browser. OK?
So in my create event I have:
Then in my step event I detect any changes in browser size, which triggers an alarm:
One second later, the alarm resets my w and h variables to the new browser-size:
Now, for my draw GUI event, I ask it to draw the title in the centre of the browser window, and then draw lines either side of it:
I've also added some extra code to help me work out what's going on with all these numbers while I troubleshoot:
Now, what do I find?
1) Firstly, 'w' does not update to browser_width. That's not happening. It stays static.
2) If I preview it as an application and resize the window, the GUI layer resizes in line with the window. If I preview it in HTML and resize the browser, it does not.
3) window_get_width is inaccurate, whether I run it as an application or on a browser. The window width should be the same as the viewport on launch. The viewport is 1024. However, the window_get_width returns as 972. The same is true of browser_width if I run it as an application. Neither function seems to return the actual width of the window or application surface.
This means that the GUI layer doesn't fill the full space and my title (which ought to be in the center) is drifting off to the left.
Any help appreciated.
*edit*
OK, I see why w doesn't update. That's my bad. Help with why the window and browser width are inaccurate would be appreciated.
I think what I want is fairly simple: to draw to my GUI layer and have that layer remain in the same place while allowing the player to resize the window or the browser. OK?
So in my create event I have:
GML:
w = browser_width;
h = browser_height;
Code:
if (browser_width != w || browser_height != h)
{
alarm[0] = room_speed;
}
Code:
w = browser_width;
h = browser_height;
Code:
draw_text(w/2 - string_width(title)/2, h/2 - (string_height(title)/2), title);
var lineY = h/2 + (string_height(title)/2 * 0.4);
draw_line(0, lineY, w/2 - string_width(title)/2 - 20, lineY);
draw_line(w, lineY, w/2 + (string_width(title)/2 + 20), lineY);
Code:
draw_text(50, 50, w);
draw_text(50, 80, window_get_width());
draw_text(50, 110, browser_width);
draw_text(50, 140, mouse_x);
1) Firstly, 'w' does not update to browser_width. That's not happening. It stays static.
2) If I preview it as an application and resize the window, the GUI layer resizes in line with the window. If I preview it in HTML and resize the browser, it does not.
3) window_get_width is inaccurate, whether I run it as an application or on a browser. The window width should be the same as the viewport on launch. The viewport is 1024. However, the window_get_width returns as 972. The same is true of browser_width if I run it as an application. Neither function seems to return the actual width of the window or application surface.
This means that the GUI layer doesn't fill the full space and my title (which ought to be in the center) is drifting off to the left.
Any help appreciated.
*edit*
OK, I see why w doesn't update. That's my bad. Help with why the window and browser width are inaccurate would be appreciated.
Last edited: