Gadot responsiveness layout for portrait and landscape

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Aafaq Zaib

Is it possible to make 4 circles in a row in landscape mode and for portrait mode, two circles move above and 2 circles move below. I need urgent guidance.

:bust_in_silhouette: Reply From: USBashka

Godot haven’t float containers, but you can use GridContainer and dynamicly change it’s colums number through the script when the screen rotates. Like this:

func _ready():
    get_tree().root.connect("size_changed", self, "_on_viewport_size_changed")

func _on_viewport_size_changed():
    if get_tree().root.get_size().x > get_tree().root.get_size().y:
        colums = 4
        colums = 2

To add to USBashka’s answer - there is also AutoGridContainer in the AssetLib for more generic solution, although I haven’t used it.

gd_question | 2022-07-28 17:19

You can also use OS.screen_orientation in the if statement

USBashka | 2022-07-29 08:09

Yeah, you’re right. And it’s also FlowContainers was added in the 3.5 version RC8 (still recommend using stable)

enter image description here

USBashka | 2022-07-29 19:05