How to determine overlap or intersection of 9-patch objects?

0 favourites
  • 4 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • I need to be able test for the overlap/intersection of 9patch objects. Sprite overlaps work, but so far I can't find any way to detect 9patch overlaps. I need to use 9patch objects because I resize them disproportionally in the layout.

    dropbox.com/s/12gprs8m5xi6hwt/9patch_intersect.c3p

    Is there any way to do this?

    Thanks for any suggestions.

    Tagged:

  • You can attach an invisible sprite to each 9patch (add them to a container). Resize/rotate the sprite with the 9patch object. Then simply check if sprites overlap.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the suggestion. For the moment, I can't see how to lock the invisible sprite's dimensions and pin it to the 9-patch object in the layout view without manually tweaking things every time I want to modify the layout. So I decided to go with an (overly complex?) solution that establishes a hit region on each 9-patch object and some code that tests for the existence of any points falling within the hit region.

    Are there any tutorials around that you'd recommend for containers?

    Thanks again.

  • You can add that invisible sprite to a container with the 9patch. Make sure that their origin image points are the same. Then simply do this On start of layout (or On Every tick):

    Sprite set position to (9patch.x, 9patch.y)

    Sprite set angle to 9patch.angle

    Sprite set width to 9patch.width

    Sprite set height to 9patch.height

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