#How to fit background image to the screen

1 messages · Page 1 of 1 (latest)

formal scarab
#

As stated in the title, I have an image with 1920x2560px size and need to resize this for mobile screens in landscape mode. I have a main Control node with a child of TextureRect. I tried every option to fit image into the screen but couldn't do it. Can anybody help me in a very detailed instructions, please?

#

I followed the instructions in the godot doc about resizing. it says it should be 1280x720 canvas_items with expand mode

reef kestrel
#

"fit" means a lot of different things! Choose one:

  • Show full image height
    • stretching width
    • with black bars
  • Show full width
    • stretching height
    • with black bars
  • Maintain aspect
    • Surrounded by black bars
formal scarab
#

idk, which one do you think is good for mobile?

reef kestrel
#

you're going to have to make choices, but basically that's the thing that's breaking for you 🙂

#

Try them all out, see what you like!

#

the config issue is on the texturerect, where you have to play with its scaling behaviors

#

you might try cover aspect/cover width (I forget which it is called)

#

which assumes your image is bigger than the space it's trying to fill

#

oh, I'm sorry, I mean center_width

#

anyway, point is, show the image at native resolution centered, to whatever height it can permit

formal scarab
#

yeah, it's ai generated so idk how to resize or modify it i am not a designer... i think my main focus is here is to fit width cause it's a landscape game

#

but the image/shop there must be also fitted/visible thoroughly

reef kestrel
#

makes sense. So smth like

expand_mode = ExpandMode.EXPAND_FIT_WIDTH_PROPORTIONAL
stretch_mode = StretchMode.STRETCH_KEEP_ASPECT_CENTERED
#

on the texture rect

formal scarab
#

is for texturerect?

reef kestrel
#

ok, tried a few, that's the version I'd try. But honestly just play with it, see what looks good to you

formal scarab
#

keep aspect covered looks more pretty though

reef kestrel
#

then do that!

#

😄

formal scarab
#

but the problem is will ui fit/resize itself to window size?

#

does it do that automatically?

reef kestrel
#

test it -- play game in the editor and use your OS to resize the game window