My game is in portrait. I've started adding support for rotating the device; right, left or upside down. I use Letterbox scale mode.
What is the best way of doing this? It feels like I'm going down a long and complicated route:
1. Catch the Event.APPLICATION_RESIZE event
2. Use application:getDeviceOrientation() to check which orientation the app has
3. Rotate Stage accordingly, and reposition all visual elements and hitboxes
Is there a more straightforward way of achieving the same thing?
Comments
If the screen needs rotating you just need to adjust the position of the single sprite to the new centered position. Then you only need to adjust the clipping value for the screen (if you clip differently than standard) and adjust things in the UI that may be out of scope for the screen - eg the score, etc... everything else should look ok.
https://deluxepixel.com
Aha, not sure if I've also enabled the required flag. Is there a reason why it needs to be set in properties AND the required plugin?
In any case, will double check and report back.
https://deluxepixel.com
1. Game starts in portrait
2. Device is turned
3. There is a brief "turning" animation (probably part of Android)
4. The visual content stays in the same place, as if the phone hadn't been turned
The main question is: Do I have to rotate the content manually, or should the auto turning deal with this? I would have assumed the latter.
In a test project, this is a screenshot in portrait (sorry, the background is white so looks a bit confusing):
And in landscape:
If the device is turned upside down, the content is rotated accordingly. Strange! Project settings attached.
https://deluxepixel.com
Likes: SinisterSoft, antix
https://deluxepixel.com
Likes: SinisterSoft
https://deluxepixel.com