|Topic was automatically imported from the old Question2Answer platform.
I am trying to use a large background image for menu background. The image is much larger than the menu window (which could be texturerect for example). Is there a way to scale the image and only show small portion of it? Using some other way?
Here is a quick example to show what I am looking for. I took two images from google and put one on top of other in gimp.
here is what the end result should look like. The white border is there just to highlight the image. The skyscraper is from a larger image.
The background image doesn’t matter.
With googling I found some mentions of textureatlas but I can’t find it in godot.
Instead of using a
TextureRect you could use a
Sprite2D Sprite2D — Godot Engine (stable) documentation in English, which has properties to set a sub-region of the texture instead the whole texture. Or it could just be the whole texture and you scale and move the sprite with a script to show the portion you want on screen.
If you want to use
TextureRect , instead of directly assigning the texture to it, create an
AtlasTexture AtlasTexture — Godot Engine (stable) documentation in English, and assign your texture inside it. Then you can choose which sub-region to render using properties of the
If you actually don’t need the part of the image outside the screen, it’s better to just crop it in an image editor.
sprite2d seems to work fine but it is a bit sketchy to set up. For some reason I don’t have texture2s available. Thanks!
voldart | 2023-07-06 15:25