June 2018
Beginner to intermediate
298 pages
7h 38m
English
Add a new signal and a new variable to Player.gd:
signal lives_changedvar lives = 0 setget set_lives
The setget statement in GDScript allows you to specify a function that will be called whenever the value of a given variable is changed. This means that when lives decreases, you can emit a signal to let the HUD know it needs to update the display:
func set_lives(value): lives = value emit_signal("lives_changed", lives)
The start() function is called by Main when a new game starts:
func start(): $Sprite.show() self.lives = 3 change_state(ALIVE)
Now, ...
Read now
Unlock full access