Problem With Exit Repeat Loop

0 favourites
  • 5 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • I have the following repeat loop in an event sheet, and I want to be able to exit the loop arbitrarily. I figured by setting the value of the global allowLoop variable to 0 that the loop would stop running, but it doesn't. I even added a button in the layout to manually set the allowLoop variable to 0, and verified the zero value when clicking the button. What am I missing?

  • This generates 100 Wait threads immediately, all timing out at the calculated time. Use the Timer behaviour to do what you want. You have complete control on stop/starting a Timer. You have no control over Wait.

  • Thanks for the explanation. If I understand how a timer would work (it's quite possible I don't), I'd need to move the action outside of the function it currently sits in, so it falls in the topmost flow of the event sheet, and enable/disable triggering of the action using the allowLoop variable. Is that right?

    In any event, I wound up using (what I believe is) a recursive function with a timed delay since it's something I can explicitly call at any time. Seems to work OK.

  • Hello netdzynr,

    You can do it like this:

    If you want a flexible Timer, set it to "Once", enable the the last action and put a variable in it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you kriand, this is really helpful. I'm not new to programming, but I'm still quite new to Construct and need to figure out all the Construct ways of coding.

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