I've having trouble with the repeat/for

Get help using Construct 2

Post » Tue Feb 03, 2015 8:36 pm

Hey guys,

It's my first post here and I feel incredibly stupid for asking this but I really can't seem to figure out what's wrong. The issue is that when I use a for/repeat (for example to cycle between 0-2 or to repeat an event 3 times) it seems to repeat infinitely instead (even if I use a stop loop with the for which gets ignored).

Here is the screenshot of the event which shows that I repeat the spawning of a single object for 3 times. It's the only piece of code in the whole project and the same effect applies if I replace it with repeat. After you'll see a screenshot showing that it's quite more than 3 once I press play..

Anybody have any idea what I'm doing wrong? I feel really stupid as I'm pretty sure this is how it's supposed to work.

Pic1.
Image

Pic2.
Image
B
3
Posts: 2
Reputation: 179

Post » Tue Feb 03, 2015 8:41 pm

You're running the loop every frame, that's why it's endlessly generating sprites -- it's not the loop running endlessly. I'm guessing you want to create your objects when you start the game. In that case, add your loop as a subevent to an "On start of layout" event, which is an event under the system object.
Moderator
B
111
S
41
G
20
Posts: 1,586
Reputation: 19,046

Post » Tue Feb 03, 2015 8:43 pm

Thanks for such a speedy reply! It didn't daunt to me to imagine the loop being started every frame. Somehow it made sense to me that if I used a loop that it would just do the loop and not make it happen every frame. It works perfectly now, thanks! I feel so dumb :P
B
3
Posts: 2
Reputation: 179


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], tarek2 and 5 guests