Quick "For Each" question

This forum is currently in read-only mode.
From the Asset Store
Logo Quiz with 150 prepared logos and answers, automatic question and answer mixing
  • I just want to know that if I have an event like this:

    Sprite: X greater than 0

    For each Sprite

    Will Construct only run the For Each loop for the Sprites with X greater than 0 or does it always cycle through every single instance of the Sprite?

  • It will pick all the sprites with x > 0.

    You can add more conditions under the loop for loop specific refinements

    eg.

    For each sprite

    PV "something" = n -> do stuff

    If you put the other condition above the for each, Construct will pick all of those first, and then do the for each. I don't know if it makes much difference, but I find it to be more reliable if the conditions are under the loop.

  • I was just thinking if it would work towards better performance. I don't have performance issues yet, but might as well take precautions.

  • I used to do that too until I read the wiki page on optimising.

    My project is usually at about 70-80% CPU waiting, so as the tutorial explains, improving CPU efficiency in events isn't going to amount to anything.

    This sort of problem is better left to the pros, I surmised .

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's a detailed explanation of how for each works:

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