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'm developing a game for Android using andEngine, and I need to detect collisions only when two objects visually collide (not in blank space of the image). In J2ME, I'm able to do that using helicopterSprite.collidesWith(buildingSprite, true).

However, andEngine only has helicopterSprite.collidesWith(buildingSprite). What is the equivalent method for andEngine? How do I invoke pixel-level collision?

share|improve this question
Considered one image . Its contains two building. when helicopter moves between the building its not collided. when helicopter hit building its collided . I make that in j2me. – JohnRaja Jul 15 '11 at 9:40

As of 14 June, 2011 andEngine hasn't added support for pixel-perfect collisions (taking transparent pixels) into account natively, as the developer's comment(as linked by 3nixios) states:

"Sorry my post was a little misleading, transparent pixels are not taken into account. Though, when working with the PhysicsBox2DExtension, you can create a Body that has the outline of your actual Sprite content." -- Nicolas Gramlich

As he mentions, you can use Box2D physics in conjunction with andEngine to provide pixel-perfect collision detection.

share|improve this answer
i.e. the exact link that I posted. – Jonathan Connell Jul 15 '11 at 17:53
@3nixios So it is! I've edited the answer to give you credit for posting the link. – Keeblebrox Jul 15 '11 at 20:18
Can u specified that which method shall i use ? – JohnRaja Jul 18 '11 at 7:16
If any one have solved this problem then please share code snippet. thanks. – AZ_ Aug 2 '11 at 5:00

Build your own bodies/fixtures/joints? This would easily allow you to make whatever body type (i.e. two separate boxes instead of one).

You could also get the bitmap of each when collision happens, and test the overlapping parts for an alpha of 0? This is effective and I have used it very easily, but it is EXTREMELY COSTLY as far as calculations for each collision. Would work with a single element using it to find collisions on a FEW other elements, but many collisions will destroy your FPS.

Here's my discussion on the AndEngine community about two specific ways I went about it: here.

share|improve this answer

AndEngine Collision Extension: This is an extension that aims to bring different collision methods (perfect or approximations) to AndEngine GLES2

Supported Collision Methods: Pixel-Perfect Collision (supports: translation, scale, rotation, screw) It also support pixel-perfect collision between pixel-perfect shapes and retangular shapes, without the need for the latter to be a pixel-perfect shape. Alpha values different from 0 (you set the threshold that identify if a pixel is solid or not) You ca unse the utils methods to check the performances in your app or to output the collision mask to check if it is what you need

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.