I got a problem that the P2 collision mesh is not properly aligned with the bitmap. Here's the sprite's bitmap: I measured the pixel coordinates on the bitmap and got this mesh:
{
"ship": [
{
"density": 2, "friction": 0, "bounce": 0,
"shape": [
16, 31,
0, 29,
16, 0,
31, 29
]
}
]
} And the CoffeeScript code:
@ship = game.add.sprite(200, 200, 'ship')
game.physics.p2.enable(@ship, true)
@ship.body.clearShapes()
@ship.body.loadPolygon('physicsData', 'ship') But as you can see in the image, the physics debug polygon (purple) is not properly aligned with the bitmap. My theory is that the bitmap is automatically centered on the physics polygon, because no matter how I tweak the values in the physics mesh, it won't align with the bitmap. For example, if I add 50 to all x coordinates in the polygon, the sprite will appear 50 pixels to the right, but the polygon will still be drawn on top of the sprite, not beside it. Is there a way to disable this?