I'm trying to learn Monogames(Old XNA) and how to develop a 2d game.

I'm in the process of animating my sprites. It works but there are somethings that are weird to me.

For some reason when animating my sprites it "changes" the position when being animated WITHOUT changing the origin. Like so


When I have not changed my origin my character "shifts" his body upwards. Something he should not do.

Now if I change the origin to be the width and height of my frame this does not happend. Like so


Ass you can see the rectangle is still changing but my character does NOT shift in its position. I can't really understand why he shifts and DOES NOT shift.

The origin is at the top-left position of the rectangle.

Why does my character position shifts? I think it's something about offset with the different heights of the frames I am unsure. I don't understand how to work with offset.


//I have sheets with more animations (IDLE,WALK etc) This is how I get correct ones
List<CustomTexture2D.Frames> currentsheet = cts.frames.FindAll(x => x.filename.Contains(_currentstate.ToString()));
//Gets the information of the current frame (width, height, position on spritesheet)
var t = currentsheet.Where(x => x.filename.Contains(_currentframe.ToString())).FirstOrDefault();
//Without changing origin
_spriteBatch.Draw(cts.Texture, position, new Rectangle(new Point(t.frame.x, t.frame.y), new Point(t.frame.w, t.frame.h)), Color.White, rotate, new Vector2(0, 0), 1, SpriteEffects.None, 1);
//With changed origin
_spriteBatch.Draw(cts.Texture, position, new Rectangle(t.frame.x, t.frame.y, t.frame.w, t.frame.h), Color.White, rotate, new Vector2(t.frame.w, t.frame.h), 1, SpriteEffects.None, 1);
  • \$\begingroup\$ Can you show us the code for each example? \$\endgroup\$
    – DMGregory
    Commented May 17, 2019 at 11:42
  • \$\begingroup\$ The code for drawing the sprite or how much of the code do you want? \$\endgroup\$
    – tirri
    Commented May 17, 2019 at 11:44
  • \$\begingroup\$ How much is required to reproduce the problem? That's usually a good metric to show enough for others to be able to offer good answers. \$\endgroup\$
    – DMGregory
    Commented May 17, 2019 at 11:45
  • \$\begingroup\$ @DMGregory added code. This is how I'm drawing the sprite. \$\endgroup\$
    – tirri
    Commented May 17, 2019 at 12:00
  • \$\begingroup\$ I don't have time to answer this now but I answered a very similar problem before. Basically, you need to set the origin point when you call the Draw method \$\endgroup\$ Commented May 17, 2019 at 22:43

1 Answer 1


If you look carefully at the first image the top left does not change position.

XNA does not know what is drawn in the sprite. So when you tell it to draw a sprite at (x,y) then it will draw that sprite at (x,y).

It's up to you to make sure the visuals actually match up. Either by making sure the character is always in the same spot relative to the top left, or by adding an offset to the (x,y) based on where the character is in the sprite.

  • \$\begingroup\$ Yeah I know that top left does not change position. But how would I calculate the offset? English is not my main language so unsure what offset means. \$\endgroup\$
    – tirri
    Commented May 17, 2019 at 12:41
  • \$\begingroup\$ @tirri, for every sprite you will need to store that offset. Those would need to be determined manually. \$\endgroup\$ Commented May 17, 2019 at 13:04
  • \$\begingroup\$ A common way to handle this offset that ratchet freak describes is to have the artist define a registration point for each frame, also called a "hotpoint" or "pivot", annotated in metadata for the animation, often made with a visual sprite editor tool. By subtracting the respective registration point when drawing each frame, you move them to a common coordinate space where the registration point is fixed at the origin, and the animation moves as needed around this controllable anchor. You can then add your desired sprite coordinates to place this anchored animation wherever you want on-screen. \$\endgroup\$
    – DMGregory
    Commented May 18, 2019 at 8:20

You must log in to answer this question.

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