![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | cabralito |
How can I create a text, and in that text count a variable number that I have (in a 2d game?
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | cabralito |
How can I create a text, and in that text count a variable number that I have (in a 2d game?
![]() |
Reply From: | jgodfrey |
Here’s a working sample. You’ll need to modify it as appropriate to fit your needs.
First, create a new, simple scene containing the following:
Node2D
Label
Next, attach the following script to the Node2D
extends Node2D
var counter = 0
func _process(delta):
counter += 1
$Label.text = "Counter: %s" % counter
In each frame, that’ll increment the value of the counter
variable and then put it in the Label
, formatted as Counter: #
.