-
Notifications
You must be signed in to change notification settings - Fork 6
ContactListener for Collision Event
CleftObsidian edited this page Oct 11, 2021
·
10 revisions
- Box2D Collision Processing Flowchart
ContactListener는 PhysicsObject 간의 충돌 시에 호출되는 메소드*를 포함하는 클래스이다.
Client는 ContactListener를 상속하는 클래스를 만들어 PhysicsWorld에 새로운 Contact Listener로 설정할 수 있다.
*BeginContact, EndContact, PreSolve, PostSolve
class ContactListener : public b2ContactListener
{
public:
void BeginContact(b2Contact* contact)
{ /* handle begin event */ }
void EndContact(b2Contact* contact)
{ /* handle end event */ }
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{ /* handle pre-solve event */ }
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
{ /* handle post-solve event */ }
};