Conflict detection with Box2d (for Android)?

Can someone explain how collision detection works with box2d for Android. I can not understand how the BBContactListener works.

BBContactListener listener = new BBContactListener(); world = new BBWorld(gravity, doSleep); world.SetContactListener(listener); 

How to use this listener? Do I have to expand the standard to create my own or how?

+4
source share
1 answer

I did not use box2d for Android, but I think the idea is there. You must implement contact handling methods. This is the way to do it in C ++.

 class ContactListener : public b2ContactListener { public: ContactListener(); ~ContactListener(); void BeginContact(b2Contact *contact) {...} void EndContact(b2Contact *contact) {...} void PreSolve (b2Contact *contact, const b2Manifold *oldManifold) {...} void PostSolve (b2Contact *contact, const b2ContactImpulse *impulse) {...} }; 

Then just pass this class to `b2World '

+1
source

Source: https://habr.com/ru/post/1392184/


All Articles