Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node2D
- const desired_ratio = 1280.0 / 800
- func _ready():
- get_tree().get_root().connect("size_changed",self,"resize")
- func resize():
- var current_ratio = OS.window_size.x / OS.window_size.y
- if current_ratio < desired_ratio: # when width is smaller
- current_ratio -= (desired_ratio - 1) / desired_ratio * current_ratio
- else:
- current_ratio = desired_ratio / current_ratio
- $Camera2D.zoom = Vector2(current_ratio, current_ratio)
Add Comment
Please, Sign In to add comment