How do I create a nested loop with condition?

Get help using Construct 2

Post » Wed Jan 28, 2015 12:41 pm

Loops do not process "too fast" or simultaneously, they have a specific and well-defined order of execution.

I'm not sure what you're even trying to do with that loop - it looks like it picks an object based on an overlap condition, then it (pointlessly?) moves it in a loop and will end up leaving it in the last position.
Scirra Founder
B
402
S
238
G
89
Posts: 24,613
Reputation: 195,993

Post » Wed Jan 28, 2015 1:28 pm

@Ashley I assumed (wrongly it seems) that if both loops are put in the same condition, Construct would process one loop first, complete it, and then move to the second loop (or process both in separate threads which you just debunked.)

If both loops are defined in a single conditional statement on Construct, how are they formed code wise and executed when the application is exported? I attempted to play with the debugger to see how it would work but either the loop only processed once or processed so fast that the variable assigned to the loop index stayed static at the top side of the loop.
Kurieus
Come visit and play Blast Box!
B
15
S
3
Posts: 205
Reputation: 1,349

Post » Wed Jan 28, 2015 3:04 pm

It nests the loops. Two loops in one event is the same as having one loop and then another loop in a subevent under that.
Scirra Founder
B
402
S
238
G
89
Posts: 24,613
Reputation: 195,993

Post » Wed Jan 28, 2015 3:06 pm

Ashley wrote:Loops do not process "too fast" or simultaneously, they have a specific and well-defined order of execution.

I'm not sure what you're even trying to do with that loop - it looks like it picks an object based on an overlap condition, then it (pointlessly?) moves it in a loop and will end up leaving it in the last position.


Have you checked my last picture? it's about a family of object(items) which is from the shop for example. When a player buy a item from a seller in the store, the algorithms start and search a empty slot in the player's bag with some items which are busy in their places. The algorithms search by testing a family overlapping another family. If false = the loop stays and results in right coordinations.

it's worth to mention that these families 1 and 2 have same objects because the first family cannot overlap same family.



And i don't think that a nested loop with condition works in subevent. I have tried it. No result.
B
3
Posts: 9
Reputation: 193

Post » Wed Jan 28, 2015 3:09 pm

spokplumpen question here is who is right Person created C2 or you?
B
257
S
42
G
15
Posts: 1,991
Reputation: 41,411

Post » Wed Jan 28, 2015 3:18 pm

It's not really important. I am not good at english and there are risks that I was misunderstood. But the main thing is that the problem is solved. There are maybe better solutions. I don't know
B
3
Posts: 9
Reputation: 193

Post » Wed Jan 28, 2015 4:15 pm

Ashley wrote:It nests the loops. Two loops in one event is the same as having one loop and then another loop in a subevent under that.


Ahh, thanks for the clarification @Ashley. As a side note then, maybe there should be a clause regarding this in the manual. This specific case is a little ambiguous. Going off of how actions and events are written to work in the manual, and understanding how loops work, I interpreted it as both loops running together. It would make more sense conceptually in the visual editor if to have a nested loop one of the loops needed to be added as a subevent.
Kurieus
Come visit and play Blast Box!
B
15
S
3
Posts: 205
Reputation: 1,349

Post » Wed Jan 28, 2015 7:35 pm

Unnatural20 wrote:located at www.scirra.com/ tutorials/ 1339/ calculating-rectangular-coverage-area


Lordshiva1948 wrote:you could do it like this as well


Have read now. Very interresting demos and tutorial. Thanks!
B
3
Posts: 9
Reputation: 193

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 7 guests