Game Development Reference
In-Depth Information
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);
void EndContact(b2Contact* contact);
void notifyObjects(b2Contact* contact, NSString* contactType);
void notifyAB(b2Contact* contact,
NSString* contactType,
b2Fixture* fixtureA,
NSObject* objA,
b2Fixture* fixtureB,
NSObject* objB);
The regular Box2D contact methods are implemented in Listing 13-19 . The Be-
ginContact and EndContact methods simply delegate the contact information to
the notifyObjects methods but also provide the information about whether it was
a begin or end contact event by passing an appropriate NSString object. The reason
it's a string and not a flag or enumeration will become clear shortly. Because you don't
care about the PreSolve and PostSolve events, they remain empty stubs, but
could be extended by also calling notifyObjects with the contact and an appropri-
ate string.
Listing 13-19 . Implementation of the Box2D Contact Methods
/// Called when two fixtures begin to touch.
void ContactListener::BeginContact(b2Contact* contact)
notifyObjects(contact, @"begin");
/// Called when two fixtures cease to touch.
void ContactListener::EndContact(b2Contact* contact)
notifyObjects(contact, @"end");
void ContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
// do nothing
Search Nedrilad ::

Custom Search