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

1 favourites
  • 3 posts
From the Asset Store
"Epic Clash of Destiny" Dramatic Battle Music Loop Asset
  • 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?

  • Try Construct 3

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

    Try 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)