Loop inside Loop

Get help using Construct 2

Post » Sun Nov 13, 2011 1:55 pm

Hello,
my Problem is to make a loop inside a loop.

I want to set up a matrix of Hexsprites.
10 ea Horizontal, 8 ea Vertical.
Every second row has a x offset plus 50 from the first row

So i create Horizontal Row with 10 Hexes with a For Loop. No Problem.
Then i will create the next Row with 10 Hexobjects and again...8 Times

Like:
For y = 1 to 8
     For x = 1 to 10
     (Build Row)
     Next x
(Inc VertPos and every 2.Time set the HorizOffset to plus 50)
Next y

I saw a Topic named: Working with 2 dimensions array
I understand a expression with loopindex.
But how does it work and look like ?

Like others here around, many thanks for developing such a great programm. Please keep on !
B
8
S
1
G
2
Posts: 13
Reputation: 1,901

Post » Sun Nov 13, 2011 2:10 pm

Use loopindex("x") and loopindex("y") to get the current iteration for each loop.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Nov 13, 2011 2:17 pm

Thank you again for your quick engagement !

But how can i do this in the event editor ?
I place a new event for the first loop.

How can i insert the 2. Loop ?
With a subgroup or how ? A Sub Event ??

Sorry for my 'dontunderstanding.

B
8
S
1
G
2
Posts: 13
Reputation: 1,901

Post » Sun Nov 13, 2011 5:33 pm

I find it:

Add Event...1.Loop
on this Event: Add Subevent -> there place the 2.Loop

Uhff..+ Greetings

(So that are Sub-Events)
May be i find out what is the purpose of Groups ?
B
8
S
1
G
2
Posts: 13
Reputation: 1,901

Post » Sun Nov 13, 2011 5:47 pm

Groups are useful for 'grouping' together sections of events, that can then be enabled/disabled at runtime. So for instance, if you had all your movement events in a Group, you could disable all movement as and when required.

Groups are good :)
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,846
Reputation: 48,293

Post » Sun Nov 13, 2011 5:55 pm

Groups are just for organisation really - you can keep long lists of events tidy with them.

You can also just right click the first loop and 'Add another condition' and add the second loop to the same event. Using a subevent also works, but IMO it looks a little tidier with both in the same event (and I think it runs a bit faster too).
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Nov 13, 2011 9:25 pm

For references you can find a capx about isometric tiling in this topic.
The logic is pretty much the same.
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,795


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 22 guests