Hand rework

This commit is contained in:
Rendo 2026-03-01 17:51:40 +05:00
commit 6bfd3a3f0f
8 changed files with 118 additions and 40 deletions

View file

@ -1,27 +1,16 @@
@tool
extends Control
@export var radius: float = 10.
@export_range(0,360,0.01,"or_greater","radians_as_degrees") var arch: float = PI/6
# 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:
var child: Card = get_child(i)
if child.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()
var angle: float = -arch+2*arch*((float(i+0.5))/get_child_count())
var pointing_up: float = angle - PI/2
child.position = lerp(child.position,get_combined_pivot_offset()+Vector2.from_angle(pointing_up) * radius-child.get_combined_pivot_offset(),0.25)