How do I use loopindex in a repeat after a wait?

0 favourites
  • 3 posts
From the Asset Store
Add calm and a lounge vibe to your games with these 8 tracks
  • Hello,

    I read the tutorials to the wait-function but the loopindex is not working as I expected.

    I'm trying to work with the loopindex after a wait, but it returns -1 everytime.

    [attachment=1:qx051y20][/attachment:qx051y20]

    [attachment=0:qx051y20][/attachment:qx051y20]

    I expected it to return 0,1,0,1.

    What am I doing wrong? Is it a bug? Or what can I do, to get the index after the wait?

    Thanks a lot!

  • The loopindex was reset because of the wait is the finished in other tick. The loopindex is cumulative only in the same tick, which works exactly like a local variable.

    To get the intended result, you need to store the loopindex in a static variable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thats not possible, cause the function with the repeat can/will be called multiple times simultaneously. The only way I can think of, would be, to create a variable dynamicly dependig on an given id in a dictionary and refer to it later on. not very beautiful, but I guess it will fit.

    but construct 2 saves the position in the event and the used objects when leaving the event cause of a wait... wouldn't it be possible to even save the repeats and their indices? sounds like a featurerequest.

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