browser_height

This variable returns the height, in pixels, of the current area of the browser (if applicable).

Syntax:

GML Code Example

browser_height


Returns: Real


Description

This variable holds the height (in pixels) of the browser the game is being run in. If no browser is present then the window size is returned. the following image illustrates how this variable relates to the rest of the positioning functions available through the Window Functions.


Example:

GML Code Example

if browser_height > window_get_height() || browser_width > window_get_width()
    {
    var xx, yy;
    if browser_width > window_get_width()
       {
       xx = (browser_width - window_get_width()) / 2;
       }
    else
       {
       xx = 0;
       }
    if browser_height > window_get_height()
       {
       yy = (browser_height - window_get_height()) / 2;
       }
    else
       {
       yy = 0;
       }
    window_set_position(xx, yy);
    }
 

The above code checks the width and height of the browser to see if either is larger than the current window width and height. If either of them are, it then calculates a new position for the game window within the browser.


Back: HTML5



No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here