How do I link two instances

Get help using Construct 2

Post » Wed Sep 19, 2012 9:06 pm

Say for example I have a button object and a door object. And I have lots of instances of each. What's the best way to link a specific button instance to a door instance.

I can think of a few possibilities: uids or indexes stored in local variables, but they seem a bit inelegant. Or is there something obvious that I'm missing.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Wed Sep 19, 2012 11:36 pm

Add an instance variable for the door and one for the button (i used the name "ID" for both)
When you add an instance of each object in the layout, set the value of the button instance's variable to the value of the door instance's variable, individualy, on the properties bar to the left, and then add an event to check if they have the same value when you click the button. if it's true, the door opens (in my example, it fades)

here, i made an example 'cause i'm not very good explaining Lobo932012-09-19 23:59:15
B
7
S
2
G
1
Posts: 32
Reputation: 1,089

Post » Thu Sep 20, 2012 6:53 pm

Actually you explained that perfectly. Thanks.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071


Return to How do I....?

Who is online

Users browsing this forum: agittm, mercuryus and 17 guests