Responsive Scalling for multiple screen sizes - I have no idea...

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Chain
:warning: Old Version Published before Godot 3 was released.

Greetings Godot Community!

I am currently working on a small game which basically always has the same screen shown. No scrolling, moving, etc.

I now want to support different Resolutions (from FullHD and down, I don’t think 2 or 4K is needed). I have read the Godot documentation about screen scalling, etc. and I played around with it, but I am not getting very far.

My current solution is seeting the stretchmode to 2D and the stretchaspect to keep. This works, but looks terrible.

See picture:

Thanks in advance!

There are several ways to deal with resizing.

In my game I took the simplest, which is basically fixing the resolution to some value and stretching it by keeping aspect ratio, leading to potential black margins, but at least I can place things where I want and all will just stretch proportionally.

Another way is to play with Control anchors. As you can see, a control can be defined as 4 margins relative to its parent, and has 4 anchors for all these 4 directions.
These anchors can be “begin”, “center”, end". This actually tells Godot which reference to take in the parent rectangle for each margin.
For example, to center a label horizontally, you would set left and right anchors to “center” and set the left and right margins to zero, or something like -halfSize ; +halfSize.
Another example: to place a label on the bottom-right of the screen at a distance of 50 pixels, set its right and bottom anchors to “end”, and respective margins to 50.
These anchors will be respected for any resolution changes, because they let you position your UI through rules instead of fixed positions.

On your screenshot, I see the background is only half-visible due to the resolution change. Is that intented?
In order to center it, you can either use a GUI node for it, or use a Camera that you center on it so that resolution changes will keep the view centered in the game world rather than the top-left point (often implies having the GUI on another layer though).

I didn’t play much with complex resolution changes yet, so maybe other people who had this problem can help. It’s possible that you could also use multiple layers scaling differently, or even use scripts if the game needs specific things to deal with scaling.

Zylann | 2017-08-30 13:03