0 Favourites

[solved] How do I loop properly through an array?

  • Hi all,

    whatever I try, I am totally blocked with looping through an array (read the manual, tutorials and others posts, but nothing helped me).

    This is how my loop is set up:

    [attachment=0:k0ykt8pf][/attachment:k0ykt8pf]

    I added the loops variable to see, if the loop is running at all, and I can see that it only runs 1 time.

    Dimensions are:

    x=100

    y=100

    z=1

    Any idea, why this does not work?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • The System -> For Each condition runs once for every instance of the Object Type you pick. In that particular case case you are making the event loop through all your Array instances (of which you only have one). If you wish to loop through the array elements, you have two options:

    Use the Array -> For Each XY element condition (you can use the Array.CurValue, Array.CurX and Array.CurY expressions within the event to access the current element, current x index and current y index respectively)

    Use two nested System -> For events from 0 to 99 and access the elements using the Array.At expression with loopindex like so:

    System -> For "X" from 0 to 99

    System -> For "Y" from 0 to 99

    ........ Do something with Array.At(loopindex("X"), loopindex("Y"))

  • thank you very much monitz87, just did that after I posted my request

    Working fine now.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,126
karshinkoff's avatar
karshinkoff
Unread hot topic
56 4,727
MPPlantOfficial's avatar
MPPlantOfficial
Unread hot topic
0 Favourites
Why is Stencyl doing better?
44 16,851
Potato's avatar
Potato