How do I set a initial condition for repeat?

0 favourites
  • 4 posts
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • From the manual:

    Simply repeat the event a given number of times. This tests any conditions following it on every repeat, and if those conditions are met also runs the actions and any sub-events on every repeat.

    How can I make a condition that will be checked once before the loop and start repeating if that condition is true?

  • The order of conditions in an event is important. This will check the condition once, and if it's true, repeat the loop 10 times:

    Condition
    Repeat 10 times
    

    This will repeat the loop 10 times, every time checking the condition:

    Repeat 10 times
    Condition
    

    You can also use sub-events to make it more clear:

    Repeat 10 times
    ... // sub-event
    ... Condition
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Til, after 10 years of obsessively refactoring event counts down, thanks for this tip lol. I might have even made some mistakes if I thought all condition was being checked every iteration regardless of order hmm....

    Although the sub event method is often useful for running actions at only the start or end of a loop.

  • oosyrag haha, I too still learning basic things about Construct. A few weeks ago someone told me that the default order of instances is based on their zIndex, not on their UID or the order they were added to the layout. I always thought that an instance with IID=0 is the instance with the lowest UID. (facepalm)

    By the way, the order of conditions is especially important when using "For each" loops. I prefer picking the instances first, then iterating them, I believe it's better for performance:

    Enemy is on screen
    Enemy is overlapping Zone
    For Each Enemy 
    ......
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)