Hi,
I'm using cocos2d-x runtime.
What would be the best way to detect collision between two skeletons, each having defined bounding box?
I have something like this:
hero->setPositionY(hero->getPositionY() + 1);
spSkeletonBounds *heroBounds = spSkeletonBounds_create();
spSkeleton_updateWorldTransform(hero->getSkeleton());
spSkeletonBounds_update(heroBounds, hero->getSkeleton(), true);
log("hero bounds: %d, %.2f %.2f %.2f %.2f ", heroBounds->count, heroBounds->minX, heroBounds->maxX, heroBounds->minY, heroBounds->maxY);
spBoundingBoxAttachment *attachment = (spBoundingBoxAttachment *) spSkeleton_getAttachmentForSlotName(hero->getSkeleton(), "peroBoundingBox", "peroBoundingBox");
spPolygon *pol = spSkeletonBounds_getPolygon(heroBounds, attachment);
log("polygon vertices: %d", pol->count/2);
int ii = 0;
for (; ii < pol->count; ii += 2) {
float x = pol->vertices[ii];
float y = pol->vertices[ii + 1];
log("x: %.2f, y: %.2f", x, y);
}
The debug output is not positioned to the location of SpineAnimation node, the location of heroBounds and vertices is always fixed to the one defined in Spine.
How would one translate the location of Polygon to the node (world) location to use this hit test:
// quick test
if (spSkeletonBounds_aabbIntersectsSkeleton(platformBounds, heroBounds)) {
// hit
}
I've seen all the posts on this topic, all examples assume that the position is somehow translated.
What am I missing?
Any input appreciated, thanks!