Menu transitions on multiple aspect ratios?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By INKnight

I’ve made a system that change the CanvasLayers offset to smoothly change between screens, like a scrolling effect. But, this only works on the default resolution (320x180). How I can change the offsets based on the game resolution, since it’ll be scaled to the device resolution? (For example, this works on 1280x720 because it’s in the same aspect ratio, but don’t work on ultrawide )
All the screens
The offsets math is: -320*n

The problem

One of the solutions is changing all the offsets on _ready() to fit the aspect ratio of the game, but since the default resolution is low, I can’t find a way to do this.


rakkarage | 2020-06-19 16:03

:bust_in_silhouette: Reply From: rakkarage
extends Control

func _ready() -> void:
	Utility.ok(get_node("..").connect("resized", self, "_onResized"))

func _onResized() -> void:
	var tex := rect_size
	var win := get_viewport_rect().size
	if win.x > win.y:
		rect_rotation = 90
		rect_scale = Vector2(win.y / tex.x, win.x / tex.y)
		rect_rotation = 0
		rect_scale = Vector2(win.x / tex.x, win.y / tex.y)