Guest User

Untitled

a guest
Aug 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. extends Node2D
  2.  
  3. const desired_ratio = 1280.0 / 800
  4.  
  5. func _ready():
  6. get_tree().get_root().connect("size_changed",self,"resize")
  7.  
  8. func resize():
  9. var current_ratio = OS.window_size.x / OS.window_size.y
  10. if current_ratio < desired_ratio: # when width is smaller
  11. current_ratio -= (desired_ratio - 1) / desired_ratio * current_ratio
  12. else:
  13. current_ratio = desired_ratio / current_ratio
  14.  
  15. $Camera2D.zoom = Vector2(current_ratio, current_ratio)
Add Comment
Please, Sign In to add comment