• Runtimes
  • How to handle overlapping BoundingBoxAttachments

Hi there,

I want to read all the boundingBoxAttachments underneath a certain point. Right now I can only read the first BoundingBox the app finds but I need to read 'all' the boxes underneath my touchpoint. Is that even possible? Or is there an alternate way to accomplish this?
I've attached a picture so you can see the overlapping boundingBoxes on the body of the flamingo. One for dragging and one for single-click-events (it needs to fart when you click on the back-part of the body).

The current code I have now (AS3-Starling).

var p : Point = new Point( touchPoint.x - skeletonAnimation.x, touchPoint.y - skeletonAnimation.y );
if ( skeletonBounds.aabbContainsPoint( p.x, p.y ) )
{
   hitArea = skeletonBounds.containsPoint( p.x, p.y );
   // I need to have an array of boundingBoxAttachments
   if( hitArea )
   {
      trace("hitArea.name:"+hitArea.name);
   }
}

I hope someone can give me a hint or help me with this. Just knowing if something is impossible would already take away some doubt. My last question, about deleting or changing the visibilty of bones was also not answered. 🙁

Happy greetings,
Dave Lenz - Ypmits Design

As you found, SkeletonBounds only returns the first one. You could write your own method, eg:

float x, y; // point to check
Array<FloatArray> polygons = skeletonBounds.getPolygons();
for (int i = 0, n = polygons.size; i < n; i++) {
   if (skeletonBounds.containsPoint(polygons.get(i), x, y)) {
      BoundingBoxAttachment box = skeletonBounds.getBoundingBoxes().get(i);
      // Do something with box here.
   }
}

I will find your other question now. Sorry about that, it's been tough to keep up with the forums since the Christmas break.

6일 후

Hi there,

Thanks. I've solved it by writing my own handler. Thanks for the pointers.