Files
brotato/scenes/ui/floating_text/floating_text.gd
T

35 lines
941 B
GDScript

extends Node2D
class_name FloatingText
@onready var value_label: Label = $ValueLabel
func setup(value: String, color) -> void:
value_label.text = value
modulate = color
scale = Vector2.ZERO
rotation = deg_to_rad(randf_range(-10, 10))
var random_scale := randf_range(0.8,1.6)
var tween := create_tween()
tween.parallel().tween_property(self, "scale", random_scale * Vector2.ONE, 0.4)
tween.parallel().tween_property(self, "global_position", global_position + Vector2.UP * 15, 0.4)
tween .tween_interval(0.5)
tween.parallel().tween_property(self,"scale", Vector2.ZERO, 0.4)
tween.parallel().tween_property(self, "modulate:a", 0.0, 0.4)
await tween.finished
queue_free()
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass