you have N frames for an animation (an idle animation for example) of a 2D character. What is the best resolution to use for each frame? The problem is that if you save the N frames such that each of them has the size of the minimal bounding box enclosing the character, when using a call like:

// draw frame i at (0,0)
sprite.frame(i).draw(0, 0)

your character movement will be wrong, that is, it will move back and forth. The other option is to set the width and height of every frame to the maximum width and height calculated using every frame.

What is, in your experience, the best practice to follow?


2 Answers 2


Both methods you describe are commonly used, each having their pros and cons.

Fixed sprite size


  • Easy to use. Some simple math can tell you the offsets


  • Wasteful. You may end up storing a lot of useless whitespace in the video-memory

Variable sprite size


  • Low video-memory footprint


  • Harder to set up, you typically need a sprite packer and a way to store and read sprite offsets
  • You need a more complicated sprite handler than a fixed-size sprite engine would require

If you are on a memory constrained device, or are using an engine that supports variable sprite sizes out of the box, I would do that. Otherwise, it's a minor issue and I would recommend using fixed sprite sizes until you have proven that you need the additional video memory.


If you weren't going to just center the sprite animation in a frame large enough to handle the data, you'd have to have additional meta data for the "anchor" of the sprite, so that you're drawing the sprite at the right location. Obviously this is a lot of wasted space.

Fortunately, any half decent texture packing tool will atlas all of those images and give you the appropriate offset for you to use.

  • 1
    \$\begingroup\$ Hi, can you elaborate more on texture atlas and the anchor point? What is the anchor point and how it is computed (by the painter of the sprites? or automatically?). Are texture atlas a way to place sprites in a single texture in order to optimize the space consumption? If so, suppose that i pack N frames of a single animation in a single texture atlas. I have to indicate by hand where each frame resides? Are there automatic tools? \$\endgroup\$
    – Luke
    Nov 9, 2011 at 9:55
  • \$\begingroup\$ As I alluded to in my comment, yes there are a lot of texture packing tools. I don't have a recommendation for any specific one. The answer to all of your questions is "yes" except the by hand bit. \$\endgroup\$
    – Tetrad
    Nov 9, 2011 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .