@tool extends Control # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta: float) -> void: var calculated_size: Vector2 = Vector2.ZERO for card: Card in get_children(): calculated_size += card.get_rect().size calculated_size.y /= get_child_count() var offset: float = 0. for i in range(get_child_count()): var card:Card = get_child(i) offset += card.get_rect().size.x if card.top_level: continue var calculated_position: Vector2 = get_combined_pivot_offset() - calculated_size * Vector2(1.-1./get_child_count(),1) + Vector2.RIGHT*offset card.position = lerp(card.position,calculated_position,0.25) func resort_by_position(): var children: Array = get_children()