How do I use a loop?

Just started using Construct 2? Post your questions here

Post » Mon May 30, 2016 1:50 pm

If I put "Wait ____ seconds" in a loop, why does it NOT wait? See my other post here:

how-do-i-create-10-objects-using-a-loop_t176464


I would really appreciate any help. I'm getting frustrated with this.
B
8
Posts: 24
Reputation: 345

Post » Mon May 30, 2016 1:52 pm

Image Image
B
25
S
14
G
139
Posts: 876
Reputation: 72,510

Post » Mon May 30, 2016 1:57 pm

The linked tutorial did not work. I want to be able to create waves of enemies, and this tutorial operates under the assumption that I want to create every wave at once on start of layout, which is NOT the case. How do I do this without using "On start of layout"??

EDIT: Keeping this up for anyone with the same question. Follow the linked tutorial, even if you don't want to start on layout. Make the loop a subevent of the event that triggers it, and put all that under "On start of layout". MadSpy I love you forever
B
8
Posts: 24
Reputation: 345

Post » Mon May 30, 2016 2:11 pm

you need two variables , lets say , makewave and count .

makewave=1.........................create object at(whatever)
every 0.5 secounds...............add 1 to count
...................if count = 10..... >makewave=0

you still need to trigger the makewave
this will create 10 objects 0.5 seconds apart until count reaches 10
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Mon May 30, 2016 2:27 pm

PixelLab wrote:If I put "Wait ____ seconds" in a loop, why does it NOT wait?


They wait. Exactly as they are supposed to do. Not as you expect them do to.

Lets slow down the loop. At 16h00 (step 1) it commands: wait 10 minutes. At 16h01 (next step in the loop) it says wait 10 minutes. At 16h02 (step 3) it waits 10 minutes. So at what time wil the wait be over?

For step 1 at 16h10 (10 minutes later then 16h00), for step 2 at 16h11, for step 3 at 16h12. Or 10 minutes later then it gets called.

Lets speed it up. Lets assume that there is virtual no time between two steps. So what happens ? It waits 10 minutes, and then all the waits are over at the same time. After 10 minutes it fires them all at once.

I gave you two ways to do this in you original post.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests