Hello, I am going through the Godot class and I receive always an error regarding calling a function that anyway is created (I think) and this is stopping me from continuing the lessons. Can you please take a look?
See codes and screenshots
hud script
extends Control
@onready var score = $Score
func set_score_label(new_score):
score.text = "SCORE: " + str(new_score)
game script
extends Node2D
var lives = 3
var score = 0
@onready var player = $Player
@onready var hud = $UI/HUD
func _ready():
hud.set_score_label(score)
func _on_deathzone_area_entered(asteroide):
asteroide.die()
func _on_player_took_damage():
lives = lives - 1
if lives == 0:
print("Game Over")
player.die()
else:
print(lives)
func _on_enemyspawner_enemy_spawned(enemy_instance):
enemy_instance.connect("died", _on_enemy_died)
add_child(enemy_instance)
func _on_enemy_died():
score += 100
hud.set_score_label(score)
When then I did not received the regarding the function, I had one saying that the line score.text = "SCORE: " + str(new_score)
was wrong, however is the same as the video.
Thank you for your help