June 2018
Beginner to intermediate
298 pages
7h 38m
English
The global singleton is a great place to keep the player's score so that it will be persistent from level to level. Start by adding a var score variable at the top of the file, and then in new_game(), add score = 0.
Now, you need to add a point whenever a coin is collected. Go to Pickup.gd and add signal coin_pickup at the top. You can emit this signal in the pickup() function:
func pickup(): match type: 'coin': emit_signal('coin_pickup', 1) $CollisionShape2D.disabled = true $Tween.start()
The value of 1 is included here in case you want to later change the number of points that coins are worth, or add other objects that add different point amounts. This signal will be used to update the display, so now you can create the HUD.
Make ...
Read now
Unlock full access