counter for 'for each' loops?

0 favourites
  • 2 posts
From the Asset Store
Make a displayed number gradually increase or decrease, making an impression of a real-time counting.
  • First, I would like to say that what you all are doing is awesome. <img src="smileys/smiley32.gif" border="0" align="middle" />

    Second, I am having a problem finding a solution for a counter I can use in my 'For Each' loop.

    My 'for each' loop used to be a function, and I was using the (loopindex) parameter to count & Function.Param(0) to access the number.

    This was very nice because I could give my object an ID that was tied to the Function.Param(0) and then access an object in an array that had the correlated position based on the Function.Param(0).

    The problem with it being a Function was that it was doing things all at once, without recognizing my sub-events.

    So then I decided to change it to a 'for each' loop, and things are working wonderfully, except I get an infinitely repeated error that says I cannot use the Funtion.Param(0) call because it is not a function... that is totally understandable.

    So, I really want to know if there is some parameter I can use to keep count of how many times my 'for each' loop runs.

    As an alternative, I was thinking, since the 'for each' loop is 'for each (instance of object)', that I could give my object instances IDs and use that to attach to my other object created within the for each loop/use it to access things in the array.

    But if there is a counter similar to Function.Param(0) that can be used in 'for each' loops I would love to know.

    Thank you all so much.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure to understand your issue, but are you aware instances already have an IID and UID values you can refer to and pick ?

    You still can use the expression "loopindex" with a "for each" loop.

    Also, if you want to check the number of iteration of a loop, you could also have a local variable and add 1 to it, this will allow you to keep some kind of counter.

    Possibly posting your capx would make it easier to understand what your issue really is.

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