4.4 Godot
I’m only new to this but i’m trying to get my UI to update the numbers on it but other than in-game events like collecting coins i can’t do it manually, I can set the int but until i collect one in game i can’t add it to in _ready()?
This is my code:
extends CanvasLayer
class_name UI
References
@onready var Lives = $LIVES
@onready var Score = $SCORE
@onready var Coins = $COINS
@onready var TimeNo = $TIMENO
@onready var WorldNo = $WORLDNO
@onready var Timenode = $Timer
@onready var total_time_seconds : int = 400
@export var WorldName: String
func _ready():
Coins = 2
update()
WorldNo.text = WorldName
Timenode.start()
func set_score(points):
Score.text = “%d” % points
func set_coins(coins):
Coins.text = “%02d” % coins
func set_lives(lives):
Lives.text = “%02d” % lives
func _on_timer_timeout():
total_time_seconds -= 1
var m = int(total_time_seconds / 60)
var s = total_time_seconds + m / 60
TimeNo.text = "%03d" % s
func update():
if Coins != null:
set_coins(Coins)