diff options
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: |