Skip to content Skip to sidebar Skip to footer

Box2D/AndEngine - ContactListener For Multiple Object Classes

I'm developing a little Android game in Java, using AndEngine for graphics and Box2D for physics - specifically, collision handling. I have some different types of objects with con

Solution 1:

You can use your single ContactListener to manage the entire world; Contact.getFixtureA/B() will return the fixtures involved in the contact. You can utilize Fixture.getBody() to get the associated Body with each collision fixture; if, for example, your Door and Enemy objects are associated with the Bodys as user data, then you can use Body.getUserData() to retrieve that.


Post a Comment for "Box2D/AndEngine - ContactListener For Multiple Object Classes"