I am making a Zelda like 2d game . My hud is a canvas layer where my hearts are located. I’ve created an item it increase the max health. I have confirmed that max health has been increased but my hud is not updating to show the change. I know I’m missing something because I’m new to programming. My first thought was when the player picks up the heart to queue free the hud and instance a new hud that would show the change. ( this is do to the ready function ) but I can’t get the hud to queue free or Instance the new one . I don’t know how to upload a zip file on here yet but I am using fornclake Zelda like tutorials on YouTube ( episode 10 and episode 9 ) for the code . Any options would be much appreciated or any help what so ever.
How to update a canvas layer
15 days later
i think in this case you should make use of signals.
So when your player picks up the item, he should emit a signal to notify other nodes that the health is updated.
For this you could add a Singleton (PlayerStats
) managing the stats of your player. You can have that singleton listen to the players signal and then signaling the HUD that health is updated. This also gives the advantage that you can access your player stats from anywhere in your game.
Hope this helps
3 years later
Megalomaniak added the Godot Help tag .