add collecting coins

This commit is contained in:
2024-12-30 01:00:26 +01:00
parent b862fa8084
commit d96963b6ef
14 changed files with 184 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
class_name ScoreComponent
extends Node
@onready var game_manager: GM = $"/root/GameManager"
func _ready():
await get_tree().process_frame
var coins = get_tree().get_nodes_in_group("coins")
for coin in coins:
coin.connect("collected", on_collected)
func on_collected(amount: int) -> void:
if not game_manager:
return
game_manager.add_coins(amount)
print("Coins: ", game_manager.get_coins())
# todo: play sound
# todo: update ui