bug arreglado
This commit is contained in:
1 parent
84c148f1ab
commit
82c7963767
4 files changed
+76
-6
No files matched your search
@@ -10,10 +10,14 @@ extends CanvasLayer
|
||||
|
||||
@onready var health_bar: ProgressBar = $HUD/HealthBar
|
||||
@onready var health_label: Label = $HUD/HealthBar/HealthLabel
|
||||
@onready var speed_label: Label = $HUD/SpeedLabel
|
||||
|
||||
var player_ref: Node
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var player: Node = get_parent()
|
||||
player_ref = player
|
||||
if player == null or not player.has_signal(&"health_changed"):
|
||||
push_error("PlayerHealthHUD must be a child of a Player with health_changed signal.")
|
||||
return
|
||||
@@ -21,6 +25,21 @@ func _ready() -> void:
|
||||
# Child _ready() runs before Player._ready(). We connect here first and the
|
||||
# Player will emit its initial health value a moment later during its _ready().
|
||||
player.connect(&"health_changed", _on_health_changed)
|
||||
if speed_label:
|
||||
speed_label.visible = false
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if player_ref == null or speed_label == null:
|
||||
return
|
||||
if "get" in player_ref and player_ref.has_method("get"):
|
||||
pass
|
||||
var t = player_ref.get("_speed_boost_timer")
|
||||
if t != null and float(t) > 0.0:
|
||||
speed_label.visible = true
|
||||
speed_label.text = "SPEED UP: %ds" % int(float(t))
|
||||
else:
|
||||
speed_label.visible = false
|
||||
|
||||
|
||||
func _on_health_changed(current_health: int, max_health: int) -> void:
|
||||
|
||||
@@ -63,3 +63,17 @@ theme_override_font_sizes/font_size = 18
|
||||
text = "HP 5 / 5"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="SpeedLabel" type="Label" parent="HUD"]
|
||||
layout_mode = 0
|
||||
offset_left = 18.0
|
||||
offset_top = 70.0
|
||||
offset_right = 278.0
|
||||
offset_bottom = 98.0
|
||||
theme_override_colors/font_color = Color(1, 0.8, 0.2, 1)
|
||||
theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9)
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "SPEED UP: 0s"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
visible = false
|
||||
Reference in new issue
Block a user