window_center

Centers the region based on the viewable or browser area.

Syntax:

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:

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.


Back: The Game Window
Next: window_handle
© Copyright YoYo Games Ltd. 2018 All Rights Reserved