Problem with Family instances

Get help using Construct 2

Post » Fri May 31, 2013 1:46 pm

Hi all, I hope you can help me with a problem I have been having using Families and instances.

On this link is a simple test case I have created to demonstrate the problem:
FamilyTest.capx
This is not exactly what I am doing in my actual app but it shows the issue nicely.

In this example I was expecting it to show me the UIDs of both the sprites in 'Family1' but it only ever shows the the UID of the sprite with UID zero.
Surely the 'is visible' event should pick both instances in `Family1`?

Any help with why it does this or what I am doing wrong would be much appreciated.

Cheers,
RR
B
17
S
4
Posts: 35
Reputation: 2,408

Post » Fri May 31, 2013 2:15 pm

Add 'for each family1' after the 'is visible' condition. Right now they are both selected, but only first one of the picked objects is referred.
B
24
S
9
G
7
Posts: 756
Reputation: 7,312

Post » Fri May 31, 2013 2:33 pm

Thanks vee41, that sorted it, very much appreciated.

I just tested it with sprites not in families and noticed it requires the same, I am amazed I got this far without hitting this before.

I also spotted that if I put in, say, a rotate action instead of the text setting it acts on both sprites, could you explain the distinction (IE why one action needs the loop and the other does not)?

Cheers,
RR

B
17
S
4
Posts: 35
Reputation: 2,408

Post » Fri May 31, 2013 3:57 pm

That is explained in detail in the for each tutorial.
Moderator
B
95
S
34
G
33
Posts: 3,007
Reputation: 27,876

Post » Fri May 31, 2013 4:42 pm

Thanks Arima,
Coming from a traditional coding background this is making my brain twist around a bit.
It looks to me like any action that changes an object will act on all picked instances, while any action that needs to access the objects properties needs the loop (so it knows which one it is getting the data from).
Cheers!
RR
B
17
S
4
Posts: 35
Reputation: 2,408


Return to How do I....?

Who is online

Users browsing this forum: donstathemonsta and 28 guests