mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-14 11:23:47 +00:00
Health in HUD
This commit is contained in:
parent
60f2797541
commit
4b4cbc037a
5 changed files with 45 additions and 10 deletions
|
|
@ -5,7 +5,15 @@ public partial class Hud : CanvasLayer
|
|||
{
|
||||
[Signal]
|
||||
public delegate void StartGameEventHandler();
|
||||
|
||||
private Label _healthLabel;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
// Assuming the HUD has a Label node named "HealthLabel"
|
||||
_healthLabel = GetNode<Label>("HealthLabel");
|
||||
}
|
||||
|
||||
public void ShowMessage(string text)
|
||||
{
|
||||
var message = GetNode<Label>("Message");
|
||||
|
|
@ -29,4 +37,9 @@ public partial class Hud : CanvasLayer
|
|||
await ToSignal(GetTree().CreateTimer(1.0), SceneTreeTimer.SignalName.Timeout);
|
||||
GetNode<Button>("StartButton").Show();
|
||||
}
|
||||
|
||||
public void UpdateHealth(float newHealth, float maxHealth)
|
||||
{
|
||||
_healthLabel.Text = $"{newHealth}/{maxHealth}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue