HUD
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.
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
On the ScoreLabel
, set the Text
property to 1
, and under Size Flags
, set Horizontal
to Fill
and Expand
. Add a custom DynamicFont
using res://assets/Kenney Thick.ttf
from the assets
folder, with a font size of 48
. In the Custom Colors
section, set the Font Color
to white
and the Font Color...