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 designing a game for Android using Surface View. When a bullet hits any point on an alien it should blow the alien up. I wrote some code to detect collisions, but my code only triggers when my bullet hits the exact (x,y) coordinates of the alien. How do I write the collision-detection system so the alien will blow up wherever the bullet hit it?

share|improve this question
You've explained exactly nothing. – knight666 Jun 19 '12 at 10:00

In most cases I was happy with measuring the distance between the center of the sprite and the center of the bullet. When it is small enough blow up the unit...preferably a greedy money-obsessed "human," not a good and green "alien!"

Pythagoras and his theorem are your friend...

share|improve this answer

You need to check if you bullet is touching any part of image, if image is rectangular you just check if bullet is inside rectangle. If your image is more complex then rectangle you need to do pixel perfect collision, that means go through all your image and check if your bullet hit some colored spot.

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.