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

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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.

  • 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.

  • 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!

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I still believe that by using a container is more simple to do it, but here you go...

  • 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.

  • You are welcome!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)