0 votes

I want the player to be able to resize the window, but I want it to keep the aspect ratio of the window when resizing.

Edit: For clarification, I don't want just the game to retain it's aspect ratio, instead I want for the entire window to keep it's aspect ratio while resizing.

Godot version 3.3.3.stable.mono
in Engine by (183 points)

1 Answer

0 votes
Best answer

Here is my kinda glitchy solution:

extends Node

const RATIO = 600.0 / 1024.0


func _ready():
    get_tree().get_root().connect("size_changed", self, "set_window_aspect_ratio")


func set_window_aspect_ratio():
    OS.window_size = Vector2(OS.window_size.x, OS.window_size.x * RATIO)

If you find a better solution please let me know!

by (7,769 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.