feat: add the ui display for the user hp; connect it to the scene manager;

This commit is contained in:
2026-09-20 20:16:54 +02:00
parent a252f9419e
commit 1655a9f8cc
2 changed files with 63 additions and 5 deletions
+61 -2
View File
@@ -3,6 +3,7 @@
[ext_resource type="Script" uid="uid://duilaa5lwqeup" path="res://Scenes/Player/player.gd" id="1_a3d8c"]
[ext_resource type="Texture2D" uid="uid://cjbvc07lh4x1b" path="res://Ninja Adventure - Asset Pack/Actor/Characters/KnightGold/SeparateAnim/Walk.png" id="2_a3d8c"]
[ext_resource type="Texture2D" uid="uid://6dmy1j0t5mqy" path="res://Ninja Adventure - Asset Pack/Items/Scroll/ScrollEmpty.png" id="3_xpcdj"]
[ext_resource type="Texture2D" uid="uid://ff3wjwfsais6" path="res://Ninja Adventure - Asset Pack/Ui/LifeReceptacle/heart_2.png" id="4_mtuoh"]
[sub_resource type="AtlasTexture" id="AtlasTexture_a3d8c"]
atlas = ExtResource("2_a3d8c")
@@ -152,6 +153,57 @@ size = Vector2(8, 8)
[sub_resource type="LabelSettings" id="LabelSettings_chgu2"]
font_size = 48
[sub_resource type="AtlasTexture" id="AtlasTexture_hnuln"]
atlas = ExtResource("4_mtuoh")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_aqm4k"]
atlas = ExtResource("4_mtuoh")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_rcvs5"]
atlas = ExtResource("4_mtuoh")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_h8ma5"]
atlas = ExtResource("4_mtuoh")
region = Rect2(48, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_chgu2"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_hnuln")
}],
"loop": 1,
"name": &"0_hp",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_aqm4k")
}],
"loop": 1,
"name": &"1_hp",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_rcvs5")
}],
"loop": 1,
"name": &"2_hp",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_h8ma5")
}],
"loop": 1,
"name": &"3_hp",
"speed": 5.0
}]
[node name="CharacterBody2D" type="CharacterBody2D" unique_id=1991398375]
collision_mask = 7
motion_mode = 1
@@ -184,9 +236,9 @@ debug_color = Color(0.9427947, 0.09120729, 0.5535774, 0.41960785)
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1672000946]
[node name="Panel" type="Panel" parent="CanvasLayer" unique_id=1717998937]
offset_left = 50.0
offset_left = 198.0
offset_top = 52.0
offset_right = 264.0
offset_right = 412.0
offset_bottom = 125.0
[node name="Label" type="Label" parent="CanvasLayer/Panel" unique_id=1669846200]
@@ -206,6 +258,13 @@ offset_right = 63.0
offset_bottom = 62.0
texture = ExtResource("3_xpcdj")
[node name="HealthBar" type="AnimatedSprite2D" parent="CanvasLayer" unique_id=102598890]
unique_name_in_owner = true
position = Vector2(114, 88)
scale = Vector2(4.7812505, 4.7812505)
sprite_frames = SubResource("SpriteFrames_chgu2")
animation = &"0_hp"
[connection signal="body_entered" from="HitBoxArea2D" to="." method="_on_hit_box_area_2d_body_entered"]
[connection signal="body_entered" from="InteractArea2D" to="." method="_on_area_2d_body_entered"]
[connection signal="body_exited" from="InteractArea2D" to="." method="_on_area_2d_body_exited"]