Slow down Repeat X Times

0 favourites
  • 6 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • I have a loop that spawns objects "Repeat X Times".

    It creates the objects so fast that they all seem to appear at once. I don't want to slow down the animations or the objects themselves but I would like to put a small delay between the object spawns so their appearance is visually staggered instead of all at once.

    I've tried "Wait" but depending on where I put it in the loop I either skip spawns and lose objects or nothing at all seems to happen.


  • Capx? :-)

  • Its not always possible to make a capx. Not without rebuilding the entire project to clean out client restricted content...

    Repeat 10 times

    Spawn Object Size 10, 10 at Position 5, 5

    Add 10 to Position X

    This spawns 10 square objects in a straight line all at the same time.

    I would like to place a slight delay between each spawn. 0.01-0.1 seconds.

    I've tried to add "Wait" in various places and it will skip spawning objects or have zero effect.

    Repeat 10 times

    *Wait 1 second*

    Spawn Object Size 10, 10 at Position 5, 5

    Add 10 to Position X

    results in object spawning being skipped and I only get the last few

    Repeat 10 times

    Spawn Object Size 10, 10 at Position 5, 5

    Add 10 to Position X

    *Wait 1 second*

    seems to have no effect and all objects spawn all at once.

    Perhaps using Repeat X Times is not the way to accomplish this? Its nice and cyclical but maybe I need to build something less procedural with the same results so I have someplace to put in my pauses?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 1. When you create a monster, set variable SpawnWait to 5000 (for 5 seconds or whatever our "tick" is... if it's 60 per second, then 60x5 = 300)

    2. On each "tick" decrement SpawnWait by 1

    3. On each "tick" check if SpawnWait = 0. If SpawnWait = 0 Create Monster (back to step 1).

    You could enhance with another boolean for IsGeneratingMonsters and add that to your checks... Or PendingMonsterCount = 3, that each time you create a monster, you also decrement that counter and factor that in...

    On each tick If PendingMonsterCount > 0 SpawnWait = Spawnwait - 1

    On each tick If PendingMonsterCount > 0 && SpawnWait = 0 CREATE MONSTER (PendingMonsterCount = PendingMonsterCount - 1, etc...

  • Counting Ticks can be tricky, because the number changes when there is lag.

    I would probably use

    "Every 1 Second" and use the variable to count if 10 were made yet.

    You could also "Count" to see how many instances there are, but if one dies it would spawn again a second later.

  • Wow thanks for the responses!

    klkitchens method is very fancy... I think I understand how it works and it solves another issue I was having without having to post about it now!!

    Paradox the Every X second and increment trigger sounds like the best option... I can adjust it easily as the number of objects to be spawned changes and as I get more or less objects I can easily change cycle time as well.

    Thanks for the great answers!

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