Trace the beginning and the end of a collision
As the names suggest, the Begin Contact Event is called when two fixtures begin to overlap, while the End Contact Event is called when two fixtures cease to overlap.
- Let's analyze the
BeginContact
function line by line:var fixtureA:b2Fixture=contact.GetFixtureA(); var fixtureB:b2Fixture=contact.GetFixtureB();
As you can see,
BeginContact
has ab2Contact
object passed as an argument. It contains all collision information we are looking for at the moment.GetFixtureA
andGetFixtureB
methods return the fixtures involved in the collision. I am saving them infixtureA
andfixtureB
variables. - Then, as I am looking for bodies, I need to get the body from a fixture. You should already know about the
GetBody ...
Get Box2D for Flash Games now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.