Question about example-project (instance variables.capx)

Just started using Construct 2? Post your questions here

Post » Sun Jul 24, 2016 2:05 am

I can't understand how the text instances get the correct sprite instance count values! :shock:
How are the text instances connected to the sprite instances ?! :?

My head is exploding please help lol
B
11
S
2
G
1
Posts: 20
Reputation: 694

Post » Sun Jul 24, 2016 9:04 am

As commented in the example:
Note Construct 2 pairs up instances by default, so this action will get the corresponding sprite's instance variable, as long as there is an equal number of text and sprite objects.


I guess this is a shortcut where expressions assume the IID of the currently picked object. I've been using C2 for 5 years now and I didn't even realize this existed... I can't find anything in the manual that documents this. Still, I wouldn't rely on it, as placement order matters and things can get messed up as you create/destroy objects or if you don't have equal instances of each object.

Containers would be a more suitable method. Alternatively you can assign label/debug text an instance variable with the UID of the object it is supposed to be associated with, and use that to pick the correct objects to update the text with.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Sun Jul 24, 2016 4:17 pm

Thanks for your reply. I read the comment in the example before but it does not reveal anything about the logic behind the entanglement. I agree with you it's nothing I would like to rely on.
B
11
S
2
G
1
Posts: 20
Reputation: 694


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests