From 72863ffa31e27f4c6be862d80472cfb897fccaea Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 19 Nov 2024 15:24:50 +0100 Subject: next commit --- UI/hp_bar.gd | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'UI/hp_bar.gd') diff --git a/UI/hp_bar.gd b/UI/hp_bar.gd index 9df85e8..bb18bf2 100644 --- a/UI/hp_bar.gd +++ b/UI/hp_bar.gd @@ -25,11 +25,30 @@ func set_value(value): visible = true +func show_numbers(value: float): + # TODO: factor out to scene + + var label = Label.new() + label.text = str(value) + label.position.x = randf_range(0.0, size.x) + label.position.y = -size.y*5 + label.add_theme_font_size_override("font_size", 8) + add_child(label) + + var tween = create_tween() + tween.tween_property(label, "position", Vector2(label.position.x, label.position.y - size.y), 0.25) + tween.tween_property(label, "self_modulate", Color(1, 1, 1, 0), 0.25) + await tween.finished + label.queue_free() + + func _on_health_bar_value_changed(value: float) -> void: if not $ImmediateDamageTimer.is_stopped(): $ImmediateDamageBar.value = $HealthBar.value + value_difference $ImmediateDamageTimer.start() + + show_numbers(value_difference) func _on_immediate_damage_timer_timeout() -> void: -- cgit v1.2.3