Center game screen for landscape layout


This Content is from Stack Overflow. Question asked by 4444

As recommended my project’s resolution is set to a 1:1 ratio (720 by 720) to accommodate Portrait and Landscape mode. I set the Stretch Mode to “viewport” and the aspect to “expand” to fit the screen to any device. I keep the Screen and Buttons as separate nodes so that I can rearrange them based on device orientation. Both nodes are children of the Game Control, which is anchored to the Center Top:

Node structure

On all devices Portrait mode works perfectly, and on most devices Landscape does too. I don’t even have to move the GreenScreen node, the program just centers it automatically when rotating to Landscape. When it does work, the layout changes like this:

Correct portrait orientation

Correct landscape orientation

However only some Android devices will behave incorrectly when it rotates to Landscape orientation. This happens instead:

Incorrect landscape orientation

This behavior persists even if I change the GreenScreen node into a Control and try to anchor it to the Center Top. How can I standardize the behavior to always center the screen on all devices? As long as the GreenScreen node always centers itself for all devices, I should be able to arrange everything else correctly.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?