Android / Amazon Fire os_lock_orientation Flipping Problem

Pogmog

Member
There is a problem that when using the function os_lock_orientation(true) on a device that is in landscape the game will be flipped 180 degrees. This has been reported in the following threads:

https://forum.yoyogames.com/index.php?threads/os_lock_orientation-issue.24398/
https://forum.yoyogames.com/index.php?threads/os_lock_orientation-is-auto-flipping-itself-if-its-in-the-reverse-orientation.22929/
https://forum.yoyogames.com/index.php?threads/os_lock_orientation-flips-my-game.24473/
https://forum.yoyogames.com/index.php?threads/how-to-lock-the-device-orientation.11626/

From testing the problem I have found out this:

If the device is orientated to "display_landscape", calling "os_lock_orientation(true)" will flip to "display_landscape_flipped" and vice versa.

If I tilt from landscape to portrait to landscape_flipped the resulting "display_get_orientation()" is 2 -> 1 -> 0. However, if I tilt from landscape to landscape_flipped the "display_get_orientation()" stays the same (e.g., 2 -> 2).

If I tilt from portrait to landscape and then call "display_get_orientation()" the screen will be flipped. However, if I tilt from portrait to landscape, then tilt to the other landscape orientation, and then call "display_get_orientation()" the screen does not flip.

These results are the same whether only the Game Global Setting have only "landscape" and "portrait" checked or if all four, including the flipped options, are checked.

Likely cause:

It seems that the display_orientation variable is set in relation to a tilt away from portrait and this setting is the opposite of what "os_lock_orientation(true)" acts on.
In other words, the "os_lock_orientation(true)" acts as if left-tilted-landscape is "0" and right-tilted-landscape is "2". However, calling "display_get_orientation()" shows left-tilted-landscape as "2" and right-tilted-landscape as "0". Thus, when the lock is called the screen is flipped.

Evidence:

To avoid the flipping behaviour you can turn the phone from portrait to landscape (setting the display_orientation variable to the conflicting value), then flip the phone to the alternate landscape orientation (resulting in a change of actual orientation but no change in the display_orientation variable). Calling "os_lock_orientation(true)" after doing this will not flip the screen because the display_orientation variable matches the orientation constants that the lock functionality uses.

Solution:

None that I can see. Any suggestions?
Part of the issue has been reported here: http://bugs.yoyogames.com/view.php?id=15291
 

GOD-sSs-END

Member
I know this is an old post, but were you ever able to fix this? I have this exact issue. When I lock the rotation using "os_lock_orientation(true)" for both Android and iOS, the preview on my phone is locked but in landscape. And this is regardless of whatever I have checked in "Orientation" under "Game Options" --> "Android". . . I tried them all.

I hope you're still around.
 

Pogmog

Member
I think I just avoided the issue. From what I remember it was a GameMaker problem, so it was a dead end.
 
Top