Repeat X times with a delay

0 favourites
  • 7 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • I am new here, and have made my best to search the forums for answers.

    I am trying to have a loop of X times, which does some action, and between actions I want a 1 second delay.

    I understand that this will not work with the "wait" command, and it has been suggested to use the "every X" command.

    But I am looking to limit the repartition somehow, and not to do the action indefinitely every 1 second.

    Any suggestion?

    Thank you very much.

  • Add the Timer behaviour to an object. Add a counter instance variable. Set your counter, start timer (repeating/regular). OnTimer, decrement counter, if 0, turn off timer.

  • Thank you very much for the quick reply.

    I was able to do it using your method, but just wanted to be clear on something. Do you mean that any object will act as my general timer?

    I mean, I used a sprite to be my timer, but I didn't really use any of its "sprite" characteristics.

    Thanks

  • That's fine. I just use a picture of a clock to remind me of it's use.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks.

    On some similar loops related subject, you might have a tip for this as well.

    I have 12 Sprite instances, trying to pick randomly one by one without repartition, and change its animation. (I wanted to do that with time gaps of 1 seconds).

    I tried using a while loop with a flag, but ended up calling 2 functions. For a programmer, this seems a little bit overkill for a simple thing.

    Is that the way this works, or am I doing something wrong and I need to learn some more of this stuff before proceeding?

  • In C2 your whole script runs every tick/(60th of a second), so there's nothing really standard for a seasoned programmer. You can't use a while loop to do timed events.

    For repetition issues, there are several threads on dealing with this. Here's one

  • Thank you for all the help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)