此函数将返回四个常量之一 GameMaker 必须告诉您运行游戏的设备是处于横向模式还是纵向模式(请参阅下表)。
请注意,在 HTML5 目标模块中使用时,此函数可能无法正确检测设备的方向。但是,使用以下脚本很容易模拟这种情况:
return (browser_width < browser_height);
这样的函数对于纵向将返回 true,对于横向将返回 false。
display_get_orientation()
显示方向常量 | |
---|---|
常量 | 描述 |
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. |
if (display_get_orientation() == display_landscape)
{
global.Config = 0;
}
else
{
global.Config = 1;
}
上述代码检查设备的方向,并根据返回的值设置全局变量。