Loop inside Loop

0 favourites
  • 7 posts
From the Asset Store
94 Inside buildings views - Isometric view - PNG transparent - 2048x2048
  • 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 !

  • Use loopindex("x") and loopindex("y") to get the current iteration for each loop.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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 ?

  • 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 :)

  • 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).

  • For references you can find a capx about isometric tiling in this topic.

    The logic is pretty much the same.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)