diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-11-19 15:24:50 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-11-19 15:24:50 +0100 |
commit | 72863ffa31e27f4c6be862d80472cfb897fccaea (patch) | |
tree | ce04be8d77b10c797c8ff854c8ff1a219eb1af46 /UI/hp_bar.gd | |
parent | 63d2a59042fb9d90a586ad85d8364de7c38aea8e (diff) |
Diffstat (limited to 'UI/hp_bar.gd')
-rw-r--r-- | UI/hp_bar.gd | 19 |
1 files changed, 19 insertions, 0 deletions
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: |