(Running on Windows 10, Godot 3.3.4)
I am very new at using Godot, in fact I've just started coding my game like tonight. First thing I'm trying to do is a display controller and I'm running into an issue.
So for the display controller I have a root node of type node, and here's the code I have for deciding what size the fullscreen window should be, and what size the window should be:
const BASE_WIDTH = 320
const BASE_HEIGHT = 200
var display_size = OS.get_screen_size()
var targeted_display_ratio = 1 # placeholder
var targeted_display_size: Vector2
var window_size = OS.get_window_size()
var targeted_window_ratio = 1 # placeholder
var targeted_window_size: Vector2
targeted_display_ratio = floor(display_size.y / BASE_HEIGHT)
targeted_display_size.x = BASE_WIDTH * targeted_display_ratio
targeted_display_size.y = BASE_HEIGHT * targeted_display_ratio
if (targeted_display_ratio < 2):
targeted_display_ratio = 2
targeted_window_size.x = BASE_WIDTH * (targeted_display_ratio - 1)
targeted_window_size.y = BASE_HEIGHT * (targeted_display_ratio -1)
The issue is while the window is resized to the correct scale (I was expecting 1280 x 800 in windowed mode and got it), the background sprite (that's all I have in my room atm) is still in its native size of 320x200, so it doesn't scale with the window. (see image below). How do I make the game itself scale with the window?
Some info: in Project Settings -> Display -> Window I have Width and Height at 320, 200. And my background sprite is of type Sprite, and is a child of Node2D (the root node of my scene, which is the first room).
Any help will be much appreciated!