➕ADD: Ataques y hud de energia mejorados
This commit is contained in:
1 parent
5d87de8ca1
commit
9b32d97d1f
6 files changed
+245
-12
No files matched your search
@@ -0,0 +1,28 @@
|
||||
extends CanvasLayer
|
||||
|
||||
|
||||
## Minimal HUD showing the player's special attack charge.
|
||||
##
|
||||
## Expects to be a child of a Player that exposes a `special_charge_changed`
|
||||
## signal, just like PlayerHealthHUD expects `health_changed`.
|
||||
|
||||
|
||||
@onready var special_bar: ProgressBar = $HUD/SpecialBar
|
||||
@onready var special_label: Label = $HUD/SpecialBar/SpecialLabel
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var player: Node = get_parent()
|
||||
if player == null or not player.has_signal(&"special_charge_changed"):
|
||||
push_error("SpecialChargeHUD must be a child of a Player with special_charge_changed signal.")
|
||||
return
|
||||
|
||||
# Child _ready() runs before Player._ready(). We connect here first and the
|
||||
# Player will emit its initial charge a moment later during its _ready().
|
||||
player.connect(&"special_charge_changed", _on_special_charge_changed)
|
||||
|
||||
|
||||
func _on_special_charge_changed(current_charge: int, max_charge: int) -> void:
|
||||
special_bar.max_value = float(max_charge)
|
||||
special_bar.value = float(current_charge)
|
||||
special_label.text = "SPECIAL %d%%" % [current_charge]
|
||||
@@ -0,0 +1,37 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/hud/special_charge_hud.gd" id="1_hud"]
|
||||
|
||||
[node name="SpecialChargeHUD" type="CanvasLayer"]
|
||||
layer = 95
|
||||
script = ExtResource("1_hud")
|
||||
|
||||
[node name="HUD" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="SpecialBar" type="ProgressBar" parent="HUD"]
|
||||
offset_left = 18.0
|
||||
offset_top = 44.0
|
||||
offset_right = 220.0
|
||||
offset_bottom = 64.0
|
||||
max_value = 100.0
|
||||
value = 0.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="SpecialLabel" type="Label" parent="HUD/SpecialBar"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
offset_left = 4.0
|
||||
offset_top = 2.0
|
||||
text = "SPECIAL"
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9)
|
||||
theme_override_constants/shadow_offset_x = 1
|
||||
theme_override_constants/shadow_offset_y = 1
|
||||
theme_override_font_sizes/font_size = 14
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
Reference in new issue
Block a user