i am listening contact between dynamic bodies. But cannot listen contact between dynamic and static bodies .
I can handle collision detection on my b2contactListener class with this metod.
public override function BeginContact(contact:b2Contact):void {
// getting the fixtures that collided
var fixtureA:b2Fixture=contact.GetFixtureA();
var fixtureB:b2Fixture=contact.GetFixtureB();
// if the fixture is a sensor, mark the parent body to be removed
if(fixtureB.GetBody().getUniqueBodyName() == "towerBody"){
//Towerbody is static body
trace("BINGOOOOOO");
}
if (fixtureA.GetBody().getUniqueBodyName() == "bomb"){
// Bomb is dynamic body
// main.gamePhysics.destroyBodyWhenCollide(fixtureA.GetBody());
var spr:Sprite = fixtureA.GetBody().GetUserData();
spr.alpha = 0;
fixtureA.GetBody().collisionDetected = true;
}
Plz help me out…
It’s not a valid assumption that the static body will be fixtureB… it could be fixtureA.
Try testing this out…