ForEach operates on SOL?

This forum is currently in read-only mode.
  • When putting a 'For Each Oject' loop as a subevent into an event that does some object picking, the loop only iterates through the picked objects. Is that the way it is supposed to work, or a bug?

    example: the following only ever fades the object spawned last

    + Every X Milliseconds
        -> Create Object A
        + For Each Object A
            -> Subtract 1 from 'Fade'
            -> Set Opacity to 'Fade'
    [/code:mqe5tw03]
    
    it works as desired when the spawning / picking is put into a subevent:
    [code:mqe5tw03]
    + Every X Milliseconds
        + Trigger once
            -> Create Object A
        + For Each Object A
            -> Subtract 1 from 'Fade'
            -> Set Opacity to 'Fade'
    [/code:mqe5tw03]
  • It's supposed to work like that, so you can for-each over a selection of objects, eg:

    + Sprite X is less than 500

    + For each Sprite

    will only for-each the sprites left of X=500. 'Create object' sets the SOL to just the created object, so for-each following a 'create' will only run once, for that instance.

    In your example, the for each is completely redundant, because both actions operate on all picked instances anyway. You could replace it with an 'always' subevent to get around the create object picking.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ah, i see. thanks!

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