Wait in for loop.

Get help using Construct 2

Post » Fri Sep 28, 2012 12:11 am

Hy, I have a loop that will go over an array(1d, width:10) and after every cycle I want the loop to wait 1 second in order to execute my animation. Well, it looks like the wait action doesn't work in a loop, any ideas?
B
15
S
3
G
2
Posts: 42
Reputation: 2,412

Post » Fri Sep 28, 2012 12:35 am

[QUOTE=wildmedia] Hy, I have a loop that will go over an array(1d, width:10) and after every cycle I want the loop to wait 1 second in order to execute my animation. Well, it looks like the wait action doesn't work in a loop, any ideas?[/QUOTE]

Cant you just make a global variable or instance variable called "Cycle_ready" or whatever :)

And then you make a event with condition "every 1 sec"/"every tick" and a bool that checks if "Cycle_ready = true" and then as an action in that event you set "Cycle_ready" to false.

After that you make another event with condition "animation finished" or whats it called and set "Cycle_ready = true" if the animation takes 1 sec.
B
40
S
10
G
2
Posts: 1,152
Reputation: 6,503

Post » Fri Sep 28, 2012 12:46 am

Nope, the game is pretty complex, I have smth similar to a shell, where the player must enter functions, such as: move, fire, turn(left)
those functions are loaded into my array, so when he triggers "the script(list of fuctions)" I have to make go all over the array and do those functions. And I want to have a little break between those functions.
B
15
S
3
G
2
Posts: 42
Reputation: 2,412

Post » Fri Sep 28, 2012 1:28 am

Sorry dont know how to do that.

Maybe an alternativ would be to give each function an index of some sort and then instead of using an array to store them you just make them as events with a build in wait function, so "the script" would be a list of numbers corresponding to the functions the player typed.

"the script(1,3,2)"

1 = move
2 = something else
3 = etc

And then you just fire of the script when the player is done entering functions.

nimos1002012-09-28 01:29:40
B
40
S
10
G
2
Posts: 1,152
Reputation: 6,503

Post » Wed Feb 06, 2013 9:59 am

Hi there,
I've just met the same problem. The feeling is exactly that "wait" step is not executed in a For loop.

Any ideas? ChyXeN2013-02-06 10:00:11
B
6
G
1
Posts: 10
Reputation: 1,048

Post » Wed Feb 06, 2013 10:10 am

I think (might be wrong as I am still a newbie) that waits inside loops are all executed at the same time.

You just need to multiply the wait by the loopindex so each loop is executed by a 1 second delay.

Something like this [CODE]System : Wait DelayAmount * loopindex[/CODE]

labithiotis2013-02-06 10:11:00
B
24
S
11
G
5
Posts: 140
Reputation: 5,004

Post » Wed Feb 06, 2013 10:11 am

[QUOTE=ChyXeN] Hi there,
I've just met the same problem. The feeling is exactly that "wait" step is not executed in a For loop.

Any ideas? [/QUOTE]

Wait step is actually executed, but loops actually run in single tick so every single execution waits for same amount of time.

Do your wait this way: Wait 1 * loopIndex seconds
B
24
S
8
G
7
Posts: 756
Reputation: 7,202


Return to How do I....?

Who is online

Users browsing this forum: farfetchd83, SpartCrafter and 20 guests