xxxxxxxxxx
29
//ContactListener to listen for collisions
class CustomListener {
//collision event functions!
BeginContact(contact) {
//get both fixtures
let f1 = contact.GetFixtureA();
let f2 = contact.GetFixtureB();
//get both bodies
let b1 = f1.GetBody();
let b2 = f2.GetBody();
//get our objects that reference these bodies
let o1 = b1.GetUserData();
let o2 = b2.GetUserData();
if (o1 instanceof Particle && o2 instanceof Particle) {
o1.change();
o2.change();
}
}
//objects stop touching each other
EndContact(contact) {};
PreSolve(contact, manifold) {};
PostSolve(contact, manifold) {};
}