2
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\begingroup\$ 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. \$\endgroup\$
    – JohnRaja
    Commented Jul 15, 2011 at 9:40
  • 7
    \$\begingroup\$ andengine.org/blog/2010/07/… ? \$\endgroup\$ Commented Jul 15, 2011 at 9:42

4 Answers 4

2
\$\begingroup\$

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.

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

This might be what you're looking for.

http://micah5.com/2011/05/30/pixel-perfect-collision-detection-for-andengine.html

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

AndEngine Collision Extension: https://github.com/MakersF/AndEngineCollisionsExtension 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

\$\endgroup\$

You must log in to answer this question.

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