extends Node2D

@onready var _damage_animation = $AnimationPlayer
@onready var _damage_label = $Label

# Called when the node enters the scene tree for the first time.
func _ready():
	visible = false

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
	pass

func show_damage(amount:int):
	visible = true
	_damage_label.visible = false
	_damage_label.set_text("%d" % amount)
	_damage_animation.play("Pop-Up", -1, 2.5)

func _on_animation_finished(anim_name):
	if anim_name == "Pop-Up":
		_damage_label.visible = true
		_damage_animation.play("Show", -1, 2.0)
	elif anim_name == "Show":
		_damage_label.visible = false
		_damage_animation.play("Fade-Out", -1, 2.5)	
	else:
		visible = false
