ForEach operates on SOL?

For questions about using Classic.

Post » Fri Jan 09, 2009 8:51 pm

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
[code:mqe5tw03]
+ 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]
B
2
S
2
G
4
Posts: 171
Reputation: 1,792

Post » Fri Jan 09, 2009 8:59 pm

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.
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,228

Post » Fri Jan 09, 2009 10:24 pm

ah, i see. thanks!
B
2
S
2
G
4
Posts: 171
Reputation: 1,792


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests