The purpose of the HUD is to display the information the player needs to know during gameplay. Collecting items will increase the player's score, so that information needs to be displayed. The player also needs to see their remaining life value, which will be displayed as a series of hearts.
HUD
Scene setup
Create a new scene with a MarginContainer node. Name it HUD and save in the ui folder. Set the Layout to Top Wide. In the Custom Constants section of Inspector, set the following values:
- Margin Right: 50
- Margin Top: 20
- Margin Left: 50
- Margin Bottom: 20
Add an HBoxContainer. This node will contain all the UI elements and keep them aligned. It will have two children:
- Label: ScoreLabel
- HBoxContainer: LifeCounter