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:
|
||||
|
||||
Reference in new issue
Block a user