androidorientationgodotlandscape

Game won't Center on Landscape devices


My 2D project uses a 1:1 ratio to accommodate Portrait or Landscape. Stretch Mode is "viewport" and Aspect is "expand" to fit any device. The GreenScreen Node fills that 1:1 space, so I reposition GrayButtons based on device orientation. Both nodes are children of a Control anchored to Center Top:

Node structure

Portrait works on all devices, and most devices handle Landscape correctly: The GreenScreen automatically centers itself in the Center Top as desired for either rotation:

Correct portrait orientation


Correct landscape orientation


However on only some Android devices, it won't center. It aligns GreenScreen to the top left corner so half the buttons are offscreen:

Incorrect landscape orientation


How can I always center the game on any device?


Solution

  • The issue remains unresolved, but my workaround was to rebuild the hierarchy and replace any Control nodes with ones from the Node2D family. Controls are apparently not reliable enough for the job, so I ditched the anchoring system and now manually calculate each Node2D's position based on the viewport dimensions.

    No more Controls