display_get_orientation

This variable holds a different constant depending on the orientation of the device.

Syntax:

display_get_orientation()


Returns: Constant


Description

This function will return one of two constant GameMaker: Studio has to tell you whether the device running the game is being held in landscape or portrait mode:

Constant Description
display_landscape The device is being held horizontally ie: The longest edge is from left to right, and the menu button is on the right.
display_landscape_flipped As above, only now the menu button is on the left.
display_portrait The device is being held vertically ie: The longest edge is from top to bottom, and the menu button is at the bottom.
display_portrait_flipped As above, only now the menu button is at the top.

Please note that this function may not correctly detect the orientation of the device when used in the HTML5 target module. However this is easily mimicked by the use of the following script:

return (browser_width < browser_height);

It will return true for portrait and false for landscape.


Example:

if display_get_orientation() = display_landscape
   {
   global.Config = 0;
   }
else
   {
   global.Config = 1;
   }

The above code checks the orientation of the device and sets a global variable depending on the value returned.


Back: Windows And Views
Next: display_get_dpi_x
© Copyright YoYo Games Ltd. 2018 All Rights Reserved