window_center

Centers the region based on the viewable or browser area.

Syntax:

GML Code Example

window_center();


Returns: N/A


Description

With this function you can center the game window in the display when the target module is Windows, Ubuntu (Linux) or MacOS, or you can center it in the browser if the target module is HTML5. This function has no effect on any other device.

NOTE: If you have resized the game window (for example, by switching from full screen to windowed), and wish to center the new window, this function should be called in an alarm[0] at least one step later than the window size change, otherwise it will not work correctly.


Example:

GML Code Example

if !window_get_fullscreen()
    {
    window_center();
    }
 

The above code will center the game window within the display if it is not in full screen mode.





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