#Aspect ratio: keep_width not working?

1 messages · Page 1 of 1 (latest)

gloomy tangle
#

Hi!

I'm trying to figure out aspect ratios. I've read the official docs and watched some tutorials online, but I still can't make Godot work the way I (and the artist) intend. We are making a simple 2D platformer.

So, the max resolution of my game should be 4K. Aspect ratios can be different, so we took a safe bet of the maximum res to be 3840x2880 (4:3). If the player's resolution is lower e.g. 1920x1080(16:9), the game should:

  • shrink to fit the width (1920x2560)
  • cut 740px from top and bottom

From what I've read keep_width should to the trick, but for some reason, it doesn't stretch to the full width.

Here I have a texture 3840x2880 with scales on it, displayed in canvas_items stretch mode and keep_width aspect setting. As you can see there are black areas on both sides.
How can I fix this?

topaz adder
#

I don't understand the logic of this resolution (1920x2560), which is 3:4. Maybe you meant 1920x1440 (4:3)?

keep_width will lock the width of your project while letting height vary. What you probably want is keep_height, which will instead lock the height and let your width vary.

gloomy tangle
#

Yep, sorry, meant 1920x1440

#

keep_width will lock the width of your project

Yes, that is what I want. The player should not see any extra scene on left or right, but top and bottom is OK

topaz adder
#

Then that picture is right. Because the window width is bigger, and to respect your 4:3 aspect ratio, Godot fill the extra space with black bars.

In this scenario, would you want that image to appear stretched horizontally while keeping it's current height?

gloomy tangle
#

Imagine the BG scaled to fit the width, and top and bottom will go off the screen

#

So far I came up with a hack of setting "Viewport height" to something small, e.g. 5px, but the "scaling" isn't centered horizontally, the image always starts from the top left corner

topaz adder
gloomy tangle
#

What I mean, is that now the BG image "starts" at the top left, I'd like it to start at the middle of Y

topaz adder
gloomy tangle
#

Oh, I see 🤔