"For Each" Family, or just Family?

Discussion and feedback on Construct 2

Post » Sun Aug 18, 2013 5:49 pm

I'm aware the "For Each" tutorial by @Arima (a great help!) and I've reviewed a few tutorials and the manual for "Families".

I'm not sure if this goes in the "How Do I...?" forum, for it's not quite a request on how to do something. I just need info and clarification.

I'm wondering if someone can give me a run-down on when I ought to use "For Each" with Families. It's my understanding that Families has a kind of For Each build into it. But that doesn't seem to be the case in certain instances.

The "behind the scenes" inner-workings of "For Each" and Families is something I don't know a lot about, so it's hard to see when I need to add "For Each" as part of the event conditions and when I can let a Families condition stand on its own.

Thanks, everyone!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
141
S
24
G
8
Posts: 791
Reputation: 15,121

Post » Sun Aug 18, 2013 5:58 pm

Don't think of everything in a family as different objects, think of them as instances.
That means you only use for each when you need to forcibly pick the object, just like you do with instances.
Image ImageImage
B
170
S
50
G
179
Posts: 8,379
Reputation: 113,427

Post » Sun Aug 18, 2013 6:19 pm

@newt - Thanks for the reminder about Families. :) I do recall that point. I guess I need to review it some more. LOL
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
141
S
24
G
8
Posts: 791
Reputation: 15,121

Post » Sun Aug 18, 2013 6:22 pm

You seem a little confused, since families aren't special in any way with regards to 'for each'. They work exactly the same as everything else.

It's conditions themselves that have a built-in for-each. See How Events Work. Lots of people make the mistake of using for-each where it is not necessary, since conditions usually check every instance anyway - try not to fall in to that trap.
Scirra Founder
B
399
S
236
G
89
Posts: 24,523
Reputation: 195,379

Post » Sun Aug 18, 2013 6:24 pm

@Ashley - Right. I do remember that, too, and I've been using For Each sparingly since I came across more information. But I'm still struggling to grasp WHEN For Each is necessary.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
141
S
24
G
8
Posts: 791
Reputation: 15,121

Post » Sun Aug 18, 2013 10:41 pm

As Ashley mentioned, families are treated the same way as other objects, so the for each tutorial should work fine for this if you read it and imagine I'm referring to a family rather than a sprite.Arima2013-08-18 22:44:32
Moderator
B
95
S
34
G
33
Posts: 3,007
Reputation: 27,876

Post » Mon Aug 19, 2013 6:20 am

@Arima - Thanks for the clarification. If it's that simple, I think I can manage. May I call on you for help if I hit a snag?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
141
S
24
G
8
Posts: 791
Reputation: 15,121

Post » Mon Aug 19, 2013 7:42 am

I'm pretty busy but if it's not too much then sure.
Moderator
B
95
S
34
G
33
Posts: 3,007
Reputation: 27,876


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests