centering ui elements in code?

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

So I am trying to make a simple 2D rythm game (think guitar hero) where circles are moving on the screen and the player has to click certain buttons at certain points.

I am fine with the general game logic but I am struggling with making it responsive and I don’t really know how to approach the topic. The game is supposed to be playable on phones so it needs to be able to work in a horizontal and vertical screen orientation.

  1. When I create the base game with the 2D nodes (sprites, position2D etc) then I struggle to scale the game.

  2. But when I use control nodes I struggle to place elements on the exact position. For example, right now I have a VBoxContainer filled with 5 NinePatchRects and that creates horizontal lines. But now when I spawn a new circle it is quite difficult to place that circle exactly on the line in a way that works when the screen dimensions change.

So I guess my question is: What is the best setup to create a responsive game?