I have a character which has a size of 32x64 when walking or standing. Using the libgdx animation class I can easily animate him with a texture atlas. When I want to make him attack however, the Sprite appears squished because the frames for the attack animation are 64x64 to accommodate the sword. My question is as the artist and programmer, would it make more sense to have each Sprite frame for every animation be 64x64? Or in code, resize the Sprite origin and bounds before the attack animation and set them back to 32x64 when the attack is done?
It's not wise to increase the size of the smaller sprites, so they fit your needs. If you have a choice, to write more code and gain efficiency - do so.
It's good that these sprites are POT because it saves you alot of memory - keep it that way.
The thing you need to do is to translate your player (and possibly other entities) positions to their center.
For now, if you draw a texture on
(0,0), you'd have it fully visible, in the left corner of the screen.
What you need to do is to translate it, so if the
width of the
64, you draw him at
(-32,0). You'd need to adjust some algorithms for it, but it's not complicated. In
GDX, you should probably override the
If you always draw your entities relative to their width-center, you can use as many animations as you want.
If you have the player's
height, in your
draw() method you can do
batch.draw(currentTexture, center.x - (currentTexture.width / 2f), center.y - (currentTexture.height / 2f), currentTexture.width, currentTexture.height);
Each texture will be rendered in the center of the player. You just have to adjust these two variables some reasonable values.
You can switch textures depending on the current state (jump, fight, whatever) - it will always work and you don't have to change the origins (you shouldn't).