How to determine the moment when all tweens finished?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dmitry Pupinin

I start tweens for several sprites. How to determine the moment when all tweens finished? Is there something like Observable? What is the best way to do it?

:bust_in_silhouette: Reply From: anakimluke

You can use Tween’s signal tween_completed!

One way of implementing this is to keep track of the number of sprites that exist and the number of signals that have been called. When the number of sprites is equal to the number of signals called, it means that all sprites have completed their tweens; assuming that no sprites are deleted, tweens are not set to repeat, there’s only one sprite per tween and one follow_* *, interpolate_*, or targeting_* * handled per tween.

*I couldn’t get these two to work, but they should also call the signal when completed, thus if you are using more than one of the those three functions per tween, you’ll have to keep track of that when updating your number_of_signals_called variable because the number of signals called will be higher than the number of sprites.