From f146c1ade2831cf3de6de9828e1340eadc0af4fe Mon Sep 17 00:00:00 2001 From: freddie-a <57713959+freddie-a@users.noreply.github.com> Date: Sun, 30 Oct 2022 01:07:18 +0100 Subject: Colour health bar --- HUD.tscn | 6 +++++- HealthBar.gd | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HUD.tscn b/HUD.tscn index 70056d4..b0f7ca6 100644 --- a/HUD.tscn +++ b/HUD.tscn @@ -1,10 +1,13 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://HealthBar.gd" type="Script" id=1] [ext_resource path="res://Wordart.gd" type="Script" id=2] [ext_resource path="res://assets/wordart.png" type="Texture" id=3] [ext_resource path="res://assets/preview_4.tres" type="AudioStream" id=4] +[sub_resource type="StyleBoxFlat" id=1] +bg_color = Color( 0, 1, 0, 1 ) + [node name="HUD" type="CanvasLayer"] [node name="HBoxContainer" type="HBoxContainer" parent="."] @@ -27,6 +30,7 @@ margin_right = 1205.0 margin_bottom = 14.0 size_flags_horizontal = 3 size_flags_vertical = 3 +custom_styles/fg = SubResource( 1 ) value = 100.0 script = ExtResource( 1 ) diff --git a/HealthBar.gd b/HealthBar.gd index 91a5b8e..57e9283 100644 --- a/HealthBar.gd +++ b/HealthBar.gd @@ -16,5 +16,7 @@ func _ready(): # pass func _on_player_hit(delta): value -= delta * 20 + var styleBox = self.get("custom_styles/fg") + styleBox.bg_color = Color.from_hsv((value) / 300, 1.0, 1.0) if value == 0: emit_signal("player_dead") -- cgit v1.2.3-70-g09d2