Files
2026-10-07 19:35:15 +08:00

20 lines
522 B
GDScript

extends Label
# Called when the node enters the scene tree for the first time.
# Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _ready():
var player = %Player
if player:
player.health_changed.connect(_on_health_changed)
_on_health_changed(player.hp,player.max_hp) # 初始化显示
print("信号已连接")
func _on_health_changed(current: int, max_hp: int):
text = "生命: %d/%d" % [current,max_hp]