Resolution rates

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

Hello all.

How can I add support for different resolution rates? I started my project as 4:3, but now I want to reapply all stuff to something at 16:9 rate.
I use a global vars that represent the WIDTH and HEIGHT of resolution and use them in some places in script.
When I change width and height properties in display section AND then change my globals, all work quite fine. The problem: is there any way to change this width and height display properties through code? Or I have to figgure out some other way to corretly apply resizing?

upd.
my project is an 2D-arcade, designed for PC, where player defending from enemies, but with some restrictions in movement. I need my game can go fullscreen as it usually goes in others. problem actually about screen rates, not about size. in project settings I set desired resolution as 1366x768, means 16:9, and when I go fullscreen it looks fine even if I set different width and height vars in code, all stuff scaled properly. BUT when I set width and height at 1024x768, e.g. 4:3, when I go fullscreen the image goes wrong. all stuff positioned as it shoud be, but stick to the left part, not centered. I just wonder, if there is other way to handle this, not just moving scene to the center.
p.s. stretch in project settings doesn’t affect behaviour for this situation

with 16:9

with 4:3

maybe Globals is what i want

yarikonline | 2016-06-05 12:25

If you could make it clearer the type of app, and the platform, etc. and exactly how you want your app to behave on different screen sizes, would be good.

duke_meister | 2016-06-05 21:39

updated post to answer your questions

yarikonline | 2016-06-06 05:44

Are you fully familiar with anchoring and margins in Godot? Having said that, I have an Android app that is portrait-only, which I ported from another engine, in which I took the easy way out and simply created over-size layout and have my UI centred… I suits my needs right now but using proper anchors/margins and relative positioning is what I should be doing. I’m pretty sure it’s what you need here.

duke_meister | 2016-06-06 22:13

ok, reread docs about this, and tried to get a new look on project. I guess I get some ideas, but then I finally tested this 4:3 on a real 4:3 display. works almost perfectly. at least if you set same resolution, as sreen’s one.

yarikonline | 2016-06-07 11:07

You need to ‘anchor’ the health bar relative to the left of screen (whatever the size), anchor the Ammo bar to the right of screen (whatever the size) and anchor the other stuff in the ‘middle’ of the screen. When you work out how to do it, let me know :slight_smile:

duke_meister | 2016-06-07 11:20

oh, I guess I didn’t correctly describe my question, 'couse there was no problems with UI. after all, I guess there was no problem at all. I asked friends to test game with different resolutions, and all of them said, that there are no problems with images. the only restriction - they must setup correct resolution in options, if they want to get fine image on fullscreen. and what I tried to show in pics - how bad will look image of I set wrong resolution.

yarikonline | 2016-06-08 04:24

:bust_in_silhouette: Reply From: Calinou

See Multiple resolutions. To resize the game window programatically, you can use OS.set_window_size(Vector2(1920, 1080)), for example.

this is not what I need. yes, it works quite well with window, but when I go fullscreen it still go messy and stick to the left part of the screen. of corse, I can just move all scene to the center of screen via some set_pos(), but objects, that must be out of screen still be visible. black squares can fix this, but I hope there is more clear and efficient way to handle different screen rates

yarikonline | 2016-06-05 16:07