Slow down Repeat X Times

Get help using Construct 2

Post » Tue Jul 30, 2013 7:33 pm

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.

Thanks!goblynn932013-07-30 19:49:46
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Tue Jul 30, 2013 9:31 pm

Capx? :-)
B
15
S
6
G
3
Posts: 87
Reputation: 4,304

Post » Tue Jul 30, 2013 9:50 pm

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?
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Tue Jul 30, 2013 10:10 pm

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...klkitchens2013-07-30 22:10:53
B
22
S
4
G
1
Posts: 100
Reputation: 2,150

Post » Tue Jul 30, 2013 10:47 pm

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.
B
226
S
59
G
32
Posts: 902
Reputation: 39,338

Post » Wed Jul 31, 2013 12:13 am

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!
B
10
S
4
G
2
Posts: 133
Reputation: 2,667


Return to How do I....?

Who is online

Users browsing this forum: vGoliath and 2 guests