played card stack can now be expanded upon hovering to see which cards were played
This commit is contained in:
@@ -5,6 +5,16 @@ var _card_height: float = 0.02
|
||||
|
||||
@export var playing_card_scene: PackedScene
|
||||
|
||||
## Surface for allowing peeking at the played cards by hovering the mouse.
|
||||
@export var peek_surface: Area3D
|
||||
|
||||
var _is_expanded: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
if peek_surface:
|
||||
peek_surface.mouse_entered.connect(_peek_mouse_entered)
|
||||
peek_surface.mouse_exited.connect(_peek_mouse_exited)
|
||||
|
||||
func add_card(card: PlayingCard) -> void:
|
||||
var height = self.get_child_count() * _card_height
|
||||
self.add_child(card)
|
||||
@@ -19,3 +29,30 @@ func add_card_by_id(card_id: int) -> void:
|
||||
func purge_cards() -> void:
|
||||
while get_child_count() > 0:
|
||||
remove_child(get_children()[get_child_count() - 1])
|
||||
|
||||
func _peek_mouse_entered() -> void:
|
||||
if get_child_count() > 1:
|
||||
var index = 0
|
||||
var child_count = get_child_count()
|
||||
for child: Node3D in get_children():
|
||||
create_tween().set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT).tween_property(
|
||||
child,
|
||||
"position",
|
||||
Vector3(0.2, index * -0.42 - (((child_count - 1) * -0.42) / 2.0), _card_height * index),
|
||||
0.3,
|
||||
)
|
||||
index += 1
|
||||
_is_expanded = true
|
||||
|
||||
func _peek_mouse_exited() -> void:
|
||||
if _is_expanded:
|
||||
var index = 0
|
||||
for child: Node3D in get_children():
|
||||
create_tween().set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT).tween_property(
|
||||
child,
|
||||
"position",
|
||||
Vector3(0.0, 0.0, _card_height * index),
|
||||
0.3,
|
||||
)
|
||||
index += 1
|
||||
_is_expanded = false
|
||||
|
||||
Reference in New Issue
Block a user