I'm trying to use the PolygonCreationAssistance class to automatically generate collision information for my sprites, but I've been having matching problems. I'll try and explain it as clearly as I can:
Suppose I start with a sprite of size 128x128 which has a drawn square of size 60x60 centered in the middle of the image. In this case if I use PolygonCreationAssistance to generate Vertices for the sprite, and then use CreatePolygonBody() and CreatePolygonGeom(),
the collision information matches the drawn sprite.
However, if I offset the square from the middle of the image to the top-left corner, for instance, the collision still happens
as if the square was still in the image center, although it is now drawn in the top-left corner.
As far as I've been able to ascertain, Vertices created by PolygonCreationAssistance have their coordinates relative to the center of each detected polygons, and not relative to the image center. For me, this seems to be a problem, since it makes it difficult
to match sprite location with physics body.
Of course I agree that typically you want to center the sprite image around drawn pixels, but it's hard to get it exactly right when working with hand-drawn sprites, and even more difficult for multi-polygon sprites (in this case, how can you simulate each
individual polygon correctly while drawing it?).
What strikes me as odd is that this problem seems to me such a fundamental one in using PolygonCreationAssistance and no one else seems to be reporting it. As such, it may be the case that I'm just misinterpreting the correct usage of PolygonCreationAssistance
in some way, and that there's a correct method somehow to achieve the correct matching.
In any case, I will appreciate any assistance you can provide me.
Best regards, thanks in advance for all the help and have a nice holiday season,