Question about the "Repeat" event

Get help using Construct 2

Post » Fri Aug 10, 2012 6:42 pm

Does Construct check at the start of the event (before the first loop is ran) and simply loops the action X amount of times, or does Construct check at the end of each loop to see if the number of loops is has performed is >= X?

My issue is that I'm working on a random level generator, and because I'm not brilliant enough to write an a perfect algorithm I simply want Construct to check if the last placement of structures is legal, and if not to delete the last structure placed and to add another structure to be placed (by increasing the loop count) to offset it. As you can guess this is only possible if Construct's Repeat event in the latter manner.
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Post » Fri Aug 10, 2012 9:43 pm

Do you mean using a variable for the repeat count? It will evaluate the repeat count expression once then run that many repeats, which I think is the first way you describe. You could try using a 'while' loop instead if you need variable behavior.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Fri Aug 10, 2012 9:51 pm

[QUOTE=kabuto202] Does Construct check at the start of the event (before the first loop is ran) and simply loops the action X amount of times, or does Construct check at the end of each loop to see if the number of loops is has performed is >= X? [/QUOTE]

Nope, C2 reads the event sheet top to bottom and executes the loops when it's "their turn" in the logical order you wrote.
When the "repeat" condition is encountered, the execution will "loop on the event" for the number of times input as parameter. (so the condition is looped as long as LoopIndex is not equal to the parameter)
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Sat Aug 11, 2012 5:14 am

Ah, curses! thanks for the quick response
B
5
S
2
G
3
Posts: 36
Reputation: 1,622


Return to How do I....?

Who is online

Users browsing this forum: anty21ro and 15 guests