- Edited
Hi,
I'm just starting out with Godot, and have some experience of C#.
My game has an energy counter in the corner which is a RichTextLabel.
The label has an Int Energy = 100 which is the Energy level, and it has a method which I was hoping to call from somewhere else to increase and decrease the Energy Level:
public void UpdateEnergy(int change)
{
Energy += change;
this.Text = "Energy: " + Energy;
}
}
Then from the Player KinematicBody2D, I want to call the UpdateEnergy, I do this by getting the Energy RichTextLabel by doing this:
Node EnergyNode = GetNode("/root/Node2D/EnergyCounter");
EnergyCounter = EnergyNode as RichTextLabel;
Then I was hoping to call:
EnergyCounter.UpdateEnergy(-10);
But I get a build error:
'RichTextLabel does not contain a definition for UpdateEnergy...'
Any advise on why I can't access UpdateEnergy? Thanks