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

I am creating a platform game, and the main character has three images for its left and right animation. The problem is that when it is walking and the player run into a block, if at that moment it switches to a stepping image which is bigger than the other imagesit gets stuck inside the block. A temporary fix to this issue was to make all the images the same size and just fill the smaller ones with white-space, however that doesn't work properly either because then the collision box is bigger than the player. Any suggestions? I also tried stretching all the images to the same size but that looked ugly.

share|improve this question
Is your collision box size changing? Does every pixel of your sprite have to be inside the collision box? – UnderscoreZero Jun 7 '13 at 15:36
I added a picture to my answer. – Nick Caplinger Jun 7 '13 at 17:09
up vote 3 down vote accepted

You should create size values that are separate from the image size. This is often called a "hitbox". This way, you can add an image of any size with any given amount of whitespace, and collisions will be unaffected.

Mario Hitboxes

Fighting games use multiple hitboxes to handle complex collisions.

enter image description here

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.