Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | MaaaxiKing |
func _ready():
while $Start.time_left >= 1.0:
print(str($Start.time_left))
is not working. The program does not react and it does not even write time_left
one single time! With if
, it is working but I need it with while
! Of course, I have the timer on autostart.
Hmmm… since ready()
is run once, after the scene is ready, this also means you forgot to check autostart
on Timer properties.
CharlesMerriam | 2021-02-06 10:59
Haha no, I wrote that I enabled it
MaaaxiKing | 2021-02-06 11:58
I have nearly no idea what is going on but my complete code that has anything to do with this issue is as follows.
func _ready():
get_tree().paused = true # Timer's pause_mode is process, SceneChanger's pause_mode is process
yield(SceneChanger, "scene_changed")
countdown()
func countdown():
while $Start.time_left >= 1.0:
print(str($Start.time_left))
$CanvasLayer/Time.text = str(round($Start.time_left)) # Time's pause_mode is process.
Script of SceneChanger-autoload:
signal scene_changed
func change_scene(scene_to_load_path, delay = 0):
if scene_to_load_path == "res://game/game.tscn":
$AnimationPlayer.play("fade")
yield($AnimationPlayer, "animation_finished")
assert(get_tree().change_scene(scene_to_load_path) == OK)
$Control/ColorRect.modulate.a = 0
emit_signal("scene_changed")
return
What i know is that countdown()
is never called because this scene waits until “scene_changed” was emitted but for some reason, it thinks it is never being emitted!? Maybe the problem was this from the beginning upsi xD.
MaaaxiKing | 2021-02-06 12:36
Okay, it’s not. When I remove the yield
line, it starts freezing again :/.
MaaaxiKing | 2021-02-06 13:01