Wait in for loop.

0 favourites
  • 7 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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
  • 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)