display_get_orientation

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

Syntax:

GML Code Example

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:

GML Code Example

return (browser_width < browser_height);
 

It will return true for portrait and false for landscape.


Example:

GML Code 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.





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