June 2018
Beginner to intermediate
298 pages
7h 38m
English
Now, you need to set up the communication between the Main scene and the HUD. Add an instance of the HUD scene to the Main scene. In the Main scene, connect the timeout() signal of GameTimer and add the following:
func _on_GameTimer_timeout(): time_left -= 1 $HUD.update_timer(time_left) if time_left <= 0: game_over()
Every time the GameTimer times out (every second), the remaining time is reduced. Next, connect the pickup() and hurt() signals of the Player:
func _on_Player_pickup(): score += 1 $HUD.update_score(score)func _on_Player_hurt(): game_over()
Several things need to happen when the game ends, so add the following function:
func game_over(): playing = false $GameTimer.stop() for coin in $CoinContainer.get_children(): ...
Read now
Unlock full access