Add a condition inside a loop?

0 favourites
  • 9 posts
From the Asset Store
Kids Game
$24.50 USD
50% off
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • Rightclick on a loop -> add condition makes the loop check a condition every time and if its true, an action can occur.

    I need to check multiple conditions inside one loop, and add an action for EVERY SINGLE condition, not for the whole set of true conditions. So i dont need to create new loops for every condition to be true too.

    Could someone explain me how to do that, maybe inside a small capx?

  • Have the loop condition as a "master" event, and then add as much sub-events as you need, with each its own set of conditions and actions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'd try this, but the sub-events seem to stay true forever. I got flooded with new sprites.

    I thought the conditions would make this thing being checked only once every loopindex. If i should use events for checking if/else parameters, whats the sense of conditions?

  • Sub-events are executed once every iteration, isn't it what you want ?

  • It is.

    I need to check the angle for each sprite. If it is 0-1 another action should happen as when the angle is 90-91.

    I tried as condition inside the for-each loop, but this puts an action for all conditions.

    When i use a sub-event, the action does not only happen every iteration, it happens like i dont use subevents. It occurs like a normal event in root.

    May this be a bug in r50?

  • You don't need a "for each" sprite loop. An event "Is between angle" will automaticly check EVERY instances of the sprite.

    So put a serie of events Sprite."Is between angle" testing from 0 to 90, another from 91 to 180, a third one from 181 to 270 and a last one from 271 to 360, and for each event you will have an action that will only happen when the condition is true.

  • If you use the For each to loop for every instance of an object, then do as Kyatric said. You have to make use of the implicit looping when you can ! <img src="smileys/smiley2.gif" border="0" align="middle" />

  • I rebuild the project, now it works fine in a for-each loop with sub-events.

    ... and for each event you will have an action that will only happen when the condition is true.

    While or when? I guess the action is performed every frame and continue as i dont check the angle in a loop.

    If not, I still need to learn few (strange) stuff about c2 <img src="smileys/smiley36.gif" border="0" align="middle" />

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