For Each Object

This forum is currently in read-only mode.
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Is there a way to stop the loop of 'for each object'?

    Say I want it to run through all the objects of a type only once.

    I want to go through all objects of a type so I could assign different values to them. But it only need to be run once and not looping through the whole game.

    Is there a way to stop it? I tried puting it on a group or in a function, but I'm not sure if it worked.

    Or are there alternatives?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could try this:

    For each

    Trigger once : action

  • The best ways are to put it in a group which you then disable, to put it in a subevent of a function, or the subevent of an event which will only trigger once.

  • Just put a condition above it that decides when to run the loop. Because conditions are read in top-to-bottom order, if conditions above the for each loop are false, it won't reach the for each loop.

    In Porlo's case you'd actually want to do

    + Trigger once

    + For each ...

    Or maybe

    + Start of layout

    + For each ...

    (Putting trigger once below the loop has no effect, because things below the loop are repeated once for each iteration of the loop)

  • Thanks Ashley, that actually worked.. I was putting the Trigger Once below that didn't work.

    I noticed the speed difference.

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