i am making a pong game, i'm trying to update the score values but because they're labels ( and therefore the text is of a string data type), i have tried casting but it doesn't work. How could i increment the values in a script
I have score labels but i cannot work out how to increment them
- Edited
Keep the score in a dedicated variable.
extends CanvasLayer:
var scoreLeft = 0
var scoreRight = 0
func _on_Ball_left():
scoreLeft += 1
$leftSideScore.text = str(scoreLeft)
func _on_Ball_right():
scoreRight += 1
$rightSideScore.text = str(scoreRight)
- Edited
- Edited
You omitted .text
.
DaveTheCoder i am very dumb, i apologise
- Edited
Making mistakes is a beneficial part of learning. (An exception would be learning to use hand grenades.)
sebthepower Don't worry about that, it's how you learn, by getting it wrong and then working out WHY you got it wrong and eventually getting it right.