I am trying to correctly handle transparent pixels. I have a spritesheet that gave me the following:
The green body is the ground physics body and the gray body around the sprite is the sprite's physics body - calculated with the bounds of the sprite. I plan on having images for the ground body of the same size, and wanted the sprite's feet to touch the ground. I was able to achieve this by repacking the images in a new spritesheet with TexturePacker, without any transparent pixels:
However, now my problem is other animations, like crouch for example:
As you can see, the sprite's feet are once again off the ground. Doing this animation in the game looks silly because the sprite crouches by lifting his feet off the ground body.
The output metadata in JSON from TexturePacker looks like this:
{
"filename": "Crouch/soldier_crouch_1.png",
"frame": {"x":712,"y":867,"w":353,"h":425},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":49,"y":42,"w":353,"h":425},
"sourceSize": {"w":433,"h":500},
"pivot": {"x":0.5,"y":0.5}
},
// ...
This is a problem for several of my animations with this and other sprites. Repacking with TexturePacker allows me to remove the transparent pixels and have a more accurate physics body (which was really the goal, I'd like the most accurate collision detection once I start having projectiles) but now the animations look funny.
How is something like this handled in game development?