Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I have 3 different sprites, that each belongs to the same sprite but with different animations type. Each has a different width, height, in the sprite sheet.

How do I adjust the 3 using math, to let them be centered, and overlapped on each other, so that when I can change their animation, and all animations are overlapped on each other. I would like to get the x,y for each sprite then, that result all of them have the same position.

share|improve this question
your question is not very clear to me, can you make it better? , maybe with some screenshots with that you are attempting to do – Joyal Jan 17 '14 at 9:17
I have 3 sprites, coming from a sprite sheet, but their frame_width, and frame_height, are different. I want to all of them have the same X,Y. I need the equation for that. For example I want all the three to be at (100,100), but the problem they won't overlap, they have different height and width. – Tolba Jan 17 '14 at 9:21

Pick a reference point for the sprite images. For example, if it's a human character, choose the point he's standing in.

Then, make sure the position of this point is consistent in all the frames. It doesn't mean all the frames have to be the same size - it could mean this point is always horizontally centered in the image, and vertically at the bottom. This may mean you have to add transparent pixels around the actual image.

Now if the character is standing at (X,Y), you just need to draw the sprite at (X - W/2, Y - H).

share|improve this answer

Your Answer


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.