Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
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? –  Setheron Sep 2 '11 at 19:39
    
If the sprite is in the center of the frame, if the origin is (0,0) different sized textures will place him differently still? –  Setheron Sep 2 '11 at 19:40
    
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 –  Joe Sep 2 '11 at 19:56
2  
I totally get it. I should go tell my friend to redraw it all! :) –  Setheron Sep 2 '11 at 20:00
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.