June 2018
Beginner to intermediate
298 pages
7h 38m
English
Add a script to the HUD node. This script will update the UI elements when their properties need to change, updating the score text whenever a coin is collected, for example. Refer to the following code:
extends CanvasLayersignal start_gamefunc update_score(value): $MarginContainer/ScoreLabel.text = str(value) func update_timer(value): $MarginContainer/TimeLabel.text = str(value)
The Main scene's script will call these functions to update the display whenever there is a change in value. For the MessageLabel, you also need a timer to make it disappear after a brief period. Add a Timer node and change its name to MessageTimer. In the Inspector, set its Wait Time to 2 seconds and check the box to set One Shot to On
Read now
Unlock full access