How do I prevent objects from clicking when an obstruct takes place?

0 favourites
  • 7 posts
From the Asset Store
Spooky Places game assets for 2D endless runner action adventure game.
  • I have 2 objects on different layers. These objects are sprites and lets say they have a circular shape. They partially intersect and so the player clearly see the object on the upper layer and partially the other object.

    when the intersection area is clicked, the object on the layer below is effected even it is not visible on the clicked area

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can try to check for an overlap and then pick the one at a higher layer so only one object is affected.

  • Add a boolean variable to your objects: Stuck = False

    Anytime you could potentially have two objects that overlap, check which one is lower and set Stuck to True

    Anytime you could potentially have two objects that no longer overlap, set both Stuck to False

    When ever you try to click an object, verify Stuck = False

  • You can try to check for an overlap and then pick the one at a higher layer so only one object is affected.

    but how can i check if there was an overlap at the very point being clicked? checking overlap only checks if the two objects are intersecting or not.

  • still could'nt find an answer

  • Here is an example of how you would only select a top instance of 2 instances of the same object.

    If you have the purchased version you can apply this to Families to allow different objects to be compared.

    If you dont have the purchased version you will have to build your own system to check which is on top. Here's the first idea I had, probably not the best option. Set a value to each object based on their ZLevel and Layer.

    If you click on more than 1 Object at a time figure out the higher of the objects and destroy that 1.

    If you click on only 1 object you will need a different event to destroy just the single.

  • Math would be much involved here since at the very point being checked. Since the two objects are circle you would likely to use integration approach to find intersection area.

    Or

    Put small object to check whether the object overlapping two objects at once.

    dropbox.com/s/c2b2pb23ecoqyg5/intersecting_area_point_check.capx

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