0 Favourites
• 3 posts
• Hi. I have a very long for loop, with thousands of iterations, on a loading layout. I wanted every iteration to add 0.00001 (for example) to a variable, and then set the loading bar to that variable every iteration, so you can see how it loads. But it justs takes a while, and then set the bar to the final value without any increment in the iterations.

I've read this tutorial scirra. com/tutorials/723/using-wait-in-loops , and tried using waits with loop index, or just setting the variable at 0.00001*loopindex, but it didn't work. Any tips on this? Thanks a lot.

• ## Try Construct 3

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

Construct 3 users don't see these ads
• A loop will start and finish in the same tick. If you don't get another tick, you won't get an update.

You can use a counter variable to increment your for loop to break up your loop into multiple frames

Lets say you need For Loop from 0 to 20000.

CounterVariable=0

You can do For Loop from CounterVariable*1000 to (CounterVariable*1000+999)

CounterVariable<20

Add another event after to increment CounterVariable by 1 while CounterVariable<20 (this should NOT be in the loop).

This will break your 20000 interations into 20 ticks - 0 to 999, 1000 to 1999, 2000 to 2999, ect.

Change the amount of iterations you want to process per frame for different resolutions of progress.

• A loop will start and finish in the same tick. If you don't get another tick, you won't get an update.

You can use a counter variable to increment your for loop to break up your loop into multiple frames

Lets say you need For Loop from 0 to 20000.

CounterVariable=0

You can do For Loop from CounterVariable*1000 to (CounterVariable*1000+999)

CounterVariable<20

Add another event after to increment CounterVariable by 1 while CounterVariable<20 (this should NOT be in the loop).

This will break your 20000 interations into 20 ticks - 0 to 999, 1000 to 1999, 2000 to 2999, ect.

Change the amount of iterations you want to process per frame for different resolutions of progress.

I didn't thought that. Thanks a lot, i can't wait to implement it!