Iteration throught arrays not working

0 favourites
  • 4 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hi. <img src="smileys/smiley1.gif" border="0" align="middle" />

    I'm new to Construct 2 and have been testing it for some days, to see what features it can provide to me.

    Then, I was testing the arrays feature to create a rectangle with objects type, so later I can implement a random dungeon algorithm.

    But then, I got a problem with it and although I have a background on programming and even OOP, couldn't figure out what is wrong.

    Here are the screenshot of the Event Sheet:

    <img src="https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-snc7/599940_326755267408388_1328991663_n.jpg" border="0" />

    My idea was to iterate over a bi-dimensional matrix where the values of each block doesn't matter, only the index of the iteration, since I can't put a For statement inside another.

    And the layout, sheet and layer are correctly associated (leaved them to default, only changed the name).

    And the object Walls have 32x32 size, but this is easily handled.

    My question is: is there anything that I should've done first? Why it doesn't iterate the loop?

    Link to project:

    sendspace.com/file/qqnsna

  • No need to create the array at the beginning. It should already exist.

    You can also set the size of it beforehand in the preferences over to the left.

    Also unless you add a trigger for each xy, it will run every tick, constantly creating objects.

    Check out some of the tutorials on sub events.

    Other than that it should work. Current x* 32, current y *32 in a 20 x 30 grid should give you 640 width x 960 height layout tho.

    Also, also, yes you can nest a for loop, again read up on sub events.

  • I've read the tutorials before, but I thought that loop iterated everything before going to the sub-events. Then I read that again and managed to work just fine!

    It was happening that it wasn't creating the objects in the screen, leaving it all white. But now with a simple trigger and For Each statement, the objects appeared.

    And guess that the array won't be necessary, by the way.

    Thanks for your response! <img src="smileys/smiley4.gif" border="0" align="middle" />

    I'm more excited about it now.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For a dungeon algo you better use the array. I did a cave algo a while ago, trying to be smart I only used sprites by filling the layout with them and then digging into but it's way slower.

    Handling cols*rows sprite is slower than an array of cols*rows data because sprites are big objects

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