How do I link 2 objects and exchange data between them?

Get help using Construct 2

Post » Sat Sep 06, 2014 5:52 pm

I've been searching for hours for a solution to my problem but couldn't find anything. Maybe I need a more simple explanation or maybe I've just overlooked a very simple solution.

Let's say I have several instances of a Square object in my layout and they each spawn a Circle object somewhere in a random location when the layout is loaded. Now how would I make it so every time a Square is clicked the circle it spawned will briefly light up? I know how to make the Square respond to a mouse click or mouse-over and I know how to make the Circle light up, I just don't know how to build that connection between them.
B
7
S
1
Posts: 29
Reputation: 483

Post » Sat Sep 06, 2014 6:22 pm

When you spawn, store the UID of the Circle in an instance variable of the Square. When you click the square, Pick the Circle by UID, and do your light-up code.
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Sat Sep 06, 2014 6:33 pm

The easiest way I can think of is by using a container. This will ensure that the Circle object is always linked (picked) with the corresponding Square object.

For the flashing effect, just use the Flash behavior.

Of course blackhornets method is also valid!
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Sat Sep 06, 2014 6:57 pm

blackhornet wrote:When you spawn, store the UID of the Circle in an instance variable of the Square. When you click the square, Pick the Circle by UID, and do your light-up code.


I had already stored the UID of the spawned object but have no idea how to pick it by UID. Could you please be more specific? I'm still a bit confused by parameters.
B
7
S
1
Posts: 29
Reputation: 483

Post » Sat Sep 06, 2014 8:05 pm

I still believe that by using a container is more simple to do it, but here you go...
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Sat Sep 06, 2014 9:03 pm

eli0s wrote:I still believe that by using a container is more simple to do it, but here you go...


Thank you. I'll have to try both versions and see how I can make use of them. As you can see I still have a lot to learn.
B
7
S
1
Posts: 29
Reputation: 483

Post » Sat Sep 06, 2014 10:02 pm

You are welcome!
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379


Return to How do I....?

Who is online

Users browsing this forum: max2612 and 14 guests