Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Tosek |
Hi there,
this code:
func _ready():
print("Staring game")
yield(Chapter1(), "completed")
print("All Done.")
func printMsg(text1) :
yield(get_tree(), "idle_frame")
print("### 1 ### " + "Durchlauf: " + text1)
printAText("!!! 2 !!!")
#yield(printAText("### 2 ###"), "completed")
yield(get_tree().create_timer(1), "timeout")
print("### 3 ###")
printAText("!!! 4 !!!")
#yield(printAText("### 4 ###"), "completed")
yield(get_tree().create_timer(1), "timeout")
print("### 5 ###")
func printAText(text):
yield(get_tree().create_timer(3), "timeout")
print(text)
yield(get_tree().create_timer(3), "timeout")
func Chapter1():
yield(get_tree(), "idle_frame")
print("Entering Chapter1")
yield(printMsg("Eins"), "completed")
yield(printMsg("Zwei"), "completed")
print("Exiting Chapter1")
results in an unexpected execution order. The output is:
Staring game
Entering Chapter1
1 ### Durchlauf: Eins
3
5
1 ### Durchlauf: Zwei
3
!!! 2 !!!
!!! 4 !!!
5
Exiting Chapter1
All Done.
!!! 2 !!!
!!! 4 !!!
But I expected:
Staring game
Entering Chapter1
1 ### Durchlauf: Eins
2
3
4
5
1 ### Durchlauf: Zwei
2
3
4
5
Exiting Chapter1
All Done.
What am I doing wrong?