You can wait for a function's completed
signal. In your case, it's
yield(create_explosion(), "completed")
For a more complete example, consider dealinitialhands below:
func deal_initial_hands():
# move_card_from_deck_to_position() ... i.e. run Tween
yield(get_tree().create_timer(0.25), "timeout")
print('a')
# move_card_from_deck_to_position() ... i.e. run Tween
yield(get_tree().create_timer(0.25), "timeout")
print('b')
# etc...
# from call site:
target.deal_initial_hands()
print('x')
If I run the code in call site (which calls deal_initial_hands()
, x
will print before a
and b
. So if e.g. you're relying on values which will be set after deal_initial_hands
at call site - then you're out of luck as they don't exist yet.
However, you can wait for deal_initial_hands
to finish by yielding to it's completed
signal instead of just calling it:
# from call site:
yield(target.deal_initial_hands(), "completed")
print('x')
Now it'll print a
, b
, then x
.