basic hp for spawnables
This commit is contained in:
10
Scenes/Spawnables/UI/SpawnableUI.gd
Normal file
10
Scenes/Spawnables/UI/SpawnableUI.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
extends Control
|
||||
|
||||
@onready var healthBar : ProgressBar = $HealthBar
|
||||
@onready var hpLabel : Label = $HealthBar/HP
|
||||
|
||||
func setHP(currentHp, maxHp):
|
||||
healthBar.min_value = 0
|
||||
healthBar.max_value = maxHp
|
||||
healthBar.value = currentHp
|
||||
hpLabel.text = str(currentHp) + "/" + str(maxHp)
|
42
Scenes/Spawnables/UI/SpawnableUI.tscn
Normal file
42
Scenes/Spawnables/UI/SpawnableUI.tscn
Normal file
@@ -0,0 +1,42 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://fojbwshce7ah"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/Spawnables/UI/SpawnableUI.gd" id="1_en1j6"]
|
||||
|
||||
[node name="SpawnableUI" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_en1j6")
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
min_value = 100.0
|
||||
step = 1.0
|
||||
value = 100.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="HP" type="Label" parent="HealthBar"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -15.5
|
||||
offset_top = -7.5
|
||||
offset_right = 15.5
|
||||
offset_bottom = 7.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_font_sizes/font_size = 8
|
||||
text = "100/100"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
Reference in New Issue
Block a user