How do I wait for all Tween play finished in the 'For each' loop?

0 favourites
  • 4 posts
From the Asset Store
Calculate parabolic trajectories and tween objects over them.
  • I want to make an opening animation of the sprites entering in order and start the game when they are all done. But How do I wait for all Tween play finished in the 'For each' loop?

    This file is to want to wait until all Tween completed, and then display the button.

    cdn.discordapp.com/attachments/253490735268102144/1113389910553022484/tween-wait-complete.c3p

    I know I can hardcode it to wait 2 seconds and display it, but I'm wondering if there is a way to use 'wait for previous actions to complete'.

    One more question, how should I make sure that the AJAX requests for files, maybe three or five files, wait for them all to finish loading before starting the header animation?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Use "Tween On Finished" event, it's the most reliable. "Wait for previous action" may not work if there are several async actions running simultaneously.

    In "Tween On Finished" event you can pick all sprites and check if any of them are still running tweens.

    Similar with AJAX, you can make a chain of AJAX requests. When the first is finished, request the second file and so on.

  • In "Tween On Finished" event you can pick all sprites and check if any of them are still running tweens.

    I tried this method but it does not seem to work. I also tried using On "Tag & loopindex" Finished to judge the last played Tween, but that doesn't seem to work either.

    It is always displayed before the last one has finished playing.

  • You can use "Wait 0.2 + Sprite.count*0.5" before making the button visible.

    Or use Timer behavior instead of "wait" inside the loop. Start a timer for each sprite instance. In "On timer" event run the tweens. Then you will be able to use loopindex to detect the last instance.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)