I'll try to explain this as best as I can.

I'm trying to build a game where there exists a "Surfer" who is surfing down a rail. I have a sprite sheet for the surfer however I have been running into animating the surfer for the following reasons:

  1. The source rectangles for each animation are sometimes different
  2. The feet of the surfer are at different locations within each texture animation.

What do I mean by #2? For instance, I have an animation for the surfer to jump rails. My spritesheet is built so that my surfer's feet might be positioned on the left side of the texture at the start of the animation and after the jump (iterating through the textures) his feet are now at the right hand side of the texture.

This is causing me problems because in order to align the feet to the rail for each animation I tried to offset the origin of the texture so that it points at his feet.

(The origin is given in the SpriteBatch.Draw call)

However this isn't working :(

Any recommendations on how to properly set this up?

PS: I Hope I explained it well, if not I can edit it and retry.


2 Answers 2


I would just fix the spritesheet. Seems like it would be a lot easier to adjust the position of each frame in the sheet rather than adjust the rectangle for each frame.

I would also try to keep him centered in each frame. You should move the sprite around by position the image, not by shifting where the image is in the frame. that just adds confusion, and complexity that you don't really need.

It doesn't really matter if the image in each rectangle is a different size. (What I mean is a guy standing vs crouching.) You should still aim to keep your source rectangle the same size. Just make the extra space transparent.

  • \$\begingroup\$ I got the artwork from a friend, so I guess I should just ask them to make it so that they are centered in each frame? Does that mean I should make the origin the center of the texture? \$\endgroup\$
    – Setheron
    Sep 2, 2011 at 19:39
  • \$\begingroup\$ If the sprite is in the center of the frame, if the origin is (0,0) different sized textures will place him differently still? \$\endgroup\$
    – Setheron
    Sep 2, 2011 at 19:40
  • \$\begingroup\$ I suggest taking a look at this starter kit. specifically how the jumping spritesheet is laid out, and how they draw it. I think it will help you. create.msdn.com/en-US/education/catalog/sample/platformer \$\endgroup\$
    – user159
    Sep 2, 2011 at 19:56
  • 2
    \$\begingroup\$ I totally get it. I should go tell my friend to redraw it all! :) \$\endgroup\$
    – Setheron
    Sep 2, 2011 at 20:00

Often, sprites like this surfer come with some kind of meta-data that describes the varying frame sizes, and hopefully the feet positions.

If you can't find this meta-data, I would recommend either making it, or following Joe's suggestion to make the frames all a standard width and height, and try to place the surfer's feet in the same (x,y) offset from the upper left corner of the frame.


You must log in to answer this question.

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