-
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 */ }
};
-
BeginContact: 충돌 순간에 호출되는 메소드
void BeginContact(b2Contact* contact) { /* handle begin event */ }
-
EndContact: