41 lines
1.1 KiB
GDScript
41 lines
1.1 KiB
GDScript
extends Control
|
|
@export var icon: Texture2D
|
|
# Called when the node enters the scene tree for the first time.
|
|
var on_select: Callable
|
|
|
|
|
|
|
|
func setup(perk: Perk, select: Callable):
|
|
$Button.modulate.a = 0
|
|
$Card/Name.text = perk.name
|
|
$Card/Description.text = perk.description
|
|
if perk.icon != null:
|
|
$Card/Name/TextureRect.texture = perk.icon
|
|
animate_in()
|
|
on_select = select
|
|
$Button.pressed.connect(_on_button_pressed)
|
|
|
|
|
|
|
|
func _on_button_pressed() -> void:
|
|
await animate_out()
|
|
on_select.call()
|
|
pass # Replace with function body.
|
|
|
|
func animate_in():
|
|
await get_tree().process_frame
|
|
var start_y = global_position.y + 500
|
|
var end_y = global_position.y
|
|
global_position.y = start_y
|
|
var tween = create_tween()
|
|
tween.tween_property(self, "global_position:y", end_y, 0.3).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_QUAD)
|
|
|
|
func animate_out():
|
|
var start_y = global_position.y
|
|
var end_y = global_position.y - 500
|
|
global_position.y = start_y
|
|
var tween = create_tween()
|
|
tween.tween_property(self, "global_position:y", end_y, 0.3).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_QUAD)
|
|
await tween.finished
|
|
|