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.

  • \$\begingroup\$ Is your collision box size changing? Does every pixel of your sprite have to be inside the collision box? \$\endgroup\$ Commented Jun 7, 2013 at 15:36
  • \$\begingroup\$ I added a picture to my answer. \$\endgroup\$ Commented Jun 7, 2013 at 17:09

1 Answer 1


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


You must log in to answer this question.

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