0 Favourites

Wait in for loop.

  • 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?

  • 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?

    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.

  • 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.

  • 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.

  • 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? <img src="smileys/smiley5.gif" border="0" align="middle" />

  • 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

    System : Wait [b]DelayAmount[/b] * loopindex
  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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? <img src="smileys/smiley5.gif" border="0" align="middle" />

    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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Topic
19 4,334
qngnht's avatar
qngnht
Unread hot topic
39 7,143
christina's avatar
christina
Unread hot topic
0 Favourites
[PLUGIN] While-loop
33 8,100
rexrainbow's avatar
rexrainbow