Collision detection in Box2D

By | April 22, 2012


Collision can be detected simply using the following lines of code with box2D.

if((contact.fixtureA == aimFixture && contact.fixtureB == tarFixture) ||
     (contact.fixtureA == tarFixture&& contact.fixtureB == aimFixture ))
        NSLog(@"Collision between aim fixture and target fixture detected!");

Here aimFixture & tarFixture are two custom fixtures whose collision you want to find out.


Leave a Reply

Your email address will not be published. Required fields are marked *