add gamemanager class and score
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,6 +1,7 @@
|
||||
extends Area2D
|
||||
|
||||
@onready var game_manager: Node = %GameManager
|
||||
|
||||
func _on_body_entered(_body: Node2D) -> void:
|
||||
print("Plus 1 coin")
|
||||
game_manager.add_point()
|
||||
queue_free()
|
||||
|
||||
9
scripts/game_manager.gd
Normal file
9
scripts/game_manager.gd
Normal file
@@ -0,0 +1,9 @@
|
||||
extends Node
|
||||
|
||||
var score = 0
|
||||
|
||||
@onready var score_label: Label = $ScoreLabel
|
||||
|
||||
func add_point():
|
||||
score += 1
|
||||
score_label.text = "You collected " + str(score) + " coins! :)"
|
||||
1
scripts/game_manager.gd.uid
Normal file
1
scripts/game_manager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://drwniyklox5wj
|
||||
Reference in New Issue
Block a user