The Pre-Solve Event is called after collision detection, but before collision resolution, so you can interact with a collision before it's solved. The Post-Solve Event occurs when a collision has been solved, and allows us to know the impulse of the collision.
Add the following two functions to the
customContact
class:override public function PreSolve(contact:b2Contact, oldManifold:b2Manifold):void { if (contact.GetManifold().m_pointCount>0) { trace("a collision has been pre solved"); var fixtureA:b2Fixture=contact.GetFixtureA(); var fixtureB:b2Fixture=contact.GetFixtureB(); var bodyA:b2Body=fixtureA.GetBody(); var bodyB:b2Body=fixtureB.GetBody(); trace("first body: "+bodyA.GetUserData()); trace("second body: "+bodyB.GetUserData()); trace("---------------------------"); } }
The
PreSolve
function at the moment has the same code asBeginContact
andEndContact
, but the code is...