![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ManiCus |
How to modify a label with a var:
If var +1 the label = +1
Iike: if var is +1 label number “2” +1 = 3
Do you get It?
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ManiCus |
How to modify a label with a var:
If var +1 the label = +1
Iike: if var is +1 label number “2” +1 = 3
Do you get It?
![]() |
Reply From: | phiz |
You can get a reference to a Node using get_node()
which takes a NodePath (ultimately could be a string) so I guess you can do what you intend using get_node()
.
There is probably a better solution for the question you’re asking, from a design perspective.
Thank you for the answer. It really helped me.
mejoresperifericos | 2020-05-17 15:39
![]() |
Reply From: | njamster |
If you want to always do this, you can use a setter-function:
var number setget set_number
func set_number(new_value):
number = new_value
get_node("Label").text = number
![]() |
Reply From: | ManiCus |
It’s me from the future …
try this:
var score = 0
signal score
func _ready():
score = 0
func _proces(delta):
update_score(score):
func update_score(score):
$label.text = str(score)
func on_signal_score(): (you have to conect de Signal with the script)
score += 1