Hi!
I created a Score-Singleton which updates score-labels using signals when 4 different texture-buttons are pressed. When running the scene, this is exactly what the Score-labels (BeziehungScore, KontrolleScore and UnterrichtScore) are doing (in the background), but the updated values won't show up in the Score-label instance. In the end, this is not a problem at all, since I only want to show the final score (= current values of the Score-labels) in an end-screen (like a high score screen). But I'm really curious why the labels are not visible when running the scene. Any ideas?
Main Scene:
extends Control
const score = preload("res://Score.tscn")
onready var handwritingsound = $HandwritingSound
onready var mainoption1 = $MainOption1
onready var mainoption2 = $MainOption2
onready var mainoption3 = $MainOption3
onready var main_option4 = $MainOption4
var Beziehungscore = 0
var Kontrollescore = 0
var Unterricht_score = 0
func ready():
var showscore = score.instance()
self.addchild(showscore)
Score.connect("update_BeziehungScore", self, "_update_Beziehung_score")
Score.connect("update_KontrolleScore", self, "_update_Kontrolle_score")
Score.connect("update_UnterrichtScore", self, "_update_Unterricht_score")
func onHandwritingSoundfinished():
handwritingsound.stop()
func onSchoolBellSoundfinished():
mainoption1.show()
mainoption2.grabfocus()
mainoption2.show()
mainoption3.show()
main_option4.show()
func onMainOption1pressed():
Score.emitsignal("updateUnterrichtScore", 10) # +10 UnterrichtScore (Pünktlichkeit)
print(Unterrichtscore)
func onMainOption2pressed():
Score.emitsignal("updateKontrolleScore", -10) # -10 KontrolleScore
print(Kontrollescore)
func onMainOption3pressed():
Score.emitsignal("updateBeziehungScore", 10) # +10 BeziehungScore, - 10 Unterricht
Score.emitsignal("update_UnterrichtScore", -10)
func onMainOption4pressed():
Score.emitsignal("updateKontrolleScore", 10) # +10 KontrolleScore , -10 Unterricht
Score.emitsignal("update_UnterrichtScore", -10)
func updateBeziehungscore(Beziehungpoints):
Beziehungscore += Beziehungpoints
Score.Beziehungscore.text = str(Beziehungscore)
func updateKontrollescore(Kontrollepoints):
Kontrollescore += Kontrollepoints
Score.Kontrollescore.text = str(Kontrollescore)
func updateUnterrichtscore(Unterrichtpoints):
Unterrichtscore += Unterrichtpoints
Score.Unterrichtscore.text = str(Unterrichtscore)
Score-Singleton:
extends Control
onready var Beziehungscore = $Beziehung/BeziehungScore
onready var Kontrollescore = $Kontrolle/KontrolleScore
onready var Unterricht_score = $Unterricht/UnterrichtScore
signal updateBeziehungScore(Beziehungpoints)
signal updateKontrolleScore(Kontrollepoints)
signal updateUnterrichtScore(Unterrichtpoints)