Some improvements
This commit is contained in:
parent
0418606bd8
commit
f816a8b886
4 changed files with 81 additions and 17 deletions
27
ui/hand.gd
Normal file
27
ui/hand.gd
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
@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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue