Topic was automatically imported from the old Question2Answer platform.
Asked By
jm4rcos
I have a progress bar and use a export var “progress” as the progress value and want it to decrease with as the timer decrease. But its not working. Here is my code:
axe_progress.visible = true
var t = Timer.new()
t.set_wait_time(4)
t.set_one_shot(true)
self.add_child(t)
t.start()
axe_progress.progress = t.time_left
yield(t, “timeout”)
axe_progress.visible = false
I don’t know where you are running this code or how you are calling it, but I think the issue could be that you are creating multiple timers, maybe.
Anyway, this code worked for me. I added a bool for timer_required so the timer was only started once. I get a countdown. Not sure it’s exactly what you want though.
if timer_required:
t = Timer.new()
t.set_wait_time(10)
t.set_one_shot(true)
self.add_child(t)
t.start()
timer_required = false
axe_progress.value = t.time_left
yield(t, "timeout")
axe_progress.visible = false