Repeat X times with a delay

Get help using Construct 2

Post » Tue Jan 14, 2014 9:37 pm

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.
B
5
Posts: 4
Reputation: 273

Post » Tue Jan 14, 2014 9:50 pm

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.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Wed Jan 15, 2014 2:50 am

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
B
5
Posts: 4
Reputation: 273

Post » Wed Jan 15, 2014 3:07 am

That's fine. I just use a picture of a clock to remind me of it's use.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Wed Jan 15, 2014 3:15 am

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?
B
5
Posts: 4
Reputation: 273

Post » Wed Jan 15, 2014 5:24 am

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
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Thu Jan 16, 2014 6:27 pm

Thank you for all the help!
B
5
Posts: 4
Reputation: 273


Return to How do I....?

Who is online

Users browsing this forum: David181, dop2000, Yahoo [Bot] and 12 guests