Object that contains the details about a contact.

🔥 Careful

Values of this instance change with every call to scan(...) so it's not meant for you to keep.

CollisionContact objects are part of an internal object pooling. This is a measure to reduce the pressure on the garbage collector.

const contactsA = collision.scan(myScanShape);       // 1st scan
const contactsA_copy = contacts.map(c => c.copy()); // copy for later use
const contactsB = collision.scan(myScanShape); // 2nd scan

console.log(contactsA); // <- BAD! Random data because of 2nd scan
console.log(contactsA_copy); // <- OK!
console.log(contactsB); // <- OK, because it's data from the last scan

Hierarchy

  • CollisionContact

Constructors

Properties

collision: Collider = null
collisionShape: CollisionShape = null
contactPoints: number[] = []

contact points encoded

length: 2 = x,y length: 4 = x1,y1 x2,y2

scan: Collider = null
scanShape: CollisionShape = null

Methods

Generated using TypeDoc