Add textured HP bars

This commit is contained in:
Raxki 2024-10-14 10:17:22 -04:00
parent 4a8434f5a8
commit bdb610b1e4
10 changed files with 181 additions and 20 deletions

View file

@ -1,7 +1,7 @@
extends Control
@onready var player_health_bar: ProgressBar = $MarginContainer/HBoxContainer/HealthBar
@onready var enemy_health_bar: ProgressBar = $MarginContainer/HBoxContainer/EnemyBar
@onready var player_health_bar: TextureProgressBar = $MarginContainer/HBoxContainer/HealthBar
@onready var enemy_health_bar: TextureProgressBar = $MarginContainer/HBoxContainer/EnemyBar
func initialize(player: PlayableCharacter, enemy: AICharacter):
player_health_bar.max_value = player.max_health

View file

@ -1,12 +1,10 @@
[gd_scene load_steps=4 format=3 uid="uid://ce2tjyxwaar01"]
[gd_scene load_steps=6 format=3 uid="uid://ce2tjyxwaar01"]
[ext_resource type="Script" path="res://Scripts/ui.gd" id="1_pbo7d"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3rm2j"]
bg_color = Color(0.12549, 0.72549, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_688ss"]
bg_color = Color(1, 0.25098, 0.262745, 1)
[ext_resource type="Texture2D" uid="uid://bavf70a0as4yp" path="res://UI/hp_bar_border_bg.png" id="2_puub5"]
[ext_resource type="Texture2D" uid="uid://bastebwa8n686" path="res://UI/hp_bar_border.png" id="3_y0hpc"]
[ext_resource type="Texture2D" uid="uid://btu7bkrjnk3ph" path="res://UI/hp_bar_green.png" id="4_vjleo"]
[ext_resource type="Texture2D" uid="uid://dp8pfpterhtai" path="res://UI/hp_bar_redpng.png" id="5_uk45e"]
[node name="UI" type="Control"]
layout_mode = 3
@ -31,26 +29,41 @@ theme_override_constants/margin_right = 16
custom_minimum_size = Vector2(0, 16)
layout_mode = 2
[node name="HealthBar" type="ProgressBar" parent="MarginContainer/HBoxContainer"]
[node name="HealthBar" type="TextureProgressBar" parent="MarginContainer/HBoxContainer"]
texture_filter = 1
custom_minimum_size = Vector2(0, 12)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
size_flags_vertical = 0
size_flags_stretch_ratio = 2.0
theme_override_styles/fill = SubResource("StyleBoxFlat_3rm2j")
step = 1.0
value = 50.0
show_percentage = false
nine_patch_stretch = true
stretch_margin_left = 4
stretch_margin_top = 4
stretch_margin_right = 4
stretch_margin_bottom = 4
texture_under = ExtResource("2_puub5")
texture_over = ExtResource("3_y0hpc")
texture_progress = ExtResource("4_vjleo")
[node name="Spacer" type="Control" parent="MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 2.0
[node name="EnemyBar" type="ProgressBar" parent="MarginContainer/HBoxContainer"]
[node name="EnemyBar" type="TextureProgressBar" parent="MarginContainer/HBoxContainer"]
texture_filter = 1
custom_minimum_size = Vector2(0, 12)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
size_flags_vertical = 0
size_flags_stretch_ratio = 2.0
theme_override_styles/fill = SubResource("StyleBoxFlat_688ss")
step = 1.0
value = 13.0
show_percentage = false
value = 50.0
nine_patch_stretch = true
stretch_margin_left = 4
stretch_margin_top = 4
stretch_margin_right = 4
stretch_margin_bottom = 4
texture_under = ExtResource("2_puub5")
texture_over = ExtResource("3_y0hpc")
texture_progress = ExtResource("5_uk45e")

BIN
UI/hp_bar_border.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bastebwa8n686"
path="res://.godot/imported/hp_bar_border.png-a32c80a7fdc781b0bf2d9852e6618966.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://UI/hp_bar_border.png"
dest_files=["res://.godot/imported/hp_bar_border.png-a32c80a7fdc781b0bf2d9852e6618966.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
UI/hp_bar_border_bg.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bavf70a0as4yp"
path="res://.godot/imported/hp_bar_border_bg.png-362420a8e13a5d9dff335822c6f738a0.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://UI/hp_bar_border_bg.png"
dest_files=["res://.godot/imported/hp_bar_border_bg.png-362420a8e13a5d9dff335822c6f738a0.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
UI/hp_bar_green.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://btu7bkrjnk3ph"
path="res://.godot/imported/hp_bar_green.png-f41c6b471c3c4ba32159cc3ea9f6a619.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://UI/hp_bar_green.png"
dest_files=["res://.godot/imported/hp_bar_green.png-f41c6b471c3c4ba32159cc3ea9f6a619.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
UI/hp_bar_redpng.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dp8pfpterhtai"
path="res://.godot/imported/hp_bar_redpng.png-9f79fa0bbd5c79f53e2343b6eccd345a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://UI/hp_bar_redpng.png"
dest_files=["res://.godot/imported/hp_bar_redpng.png-9f79fa0bbd5c79f53e2343b6eccd345a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1