Reputation: 3652
I'm using Box2D, with Libgdx for the rendering. I've implemented a ContactListener which is working fine. I however don't see how to handle the contacts. The only parameter I get is the Contact (with it's fixtures etc..), but I also need to access things like my Sprite (basically my whole actor object).
I was hoping I could somehow set a callback to my Actor object, so I could handle it there. Or maybe there could be some way to have something like mBody.setContactListener(...{})
so I can have a callback and be able to work with more than just the body or fixture.
Any help on how to go on this?
Upvotes: 2
Views: 766
Reputation: 8272
You can set a 'user data' pointer in fixtures, bodies and joints. This can be whatever information you would find useful to attach to each object. Box2D does nothing with this info, it just tells you what it was when you ask. Check out SetUserData/GetUserData in the manual.
Upvotes: 3