diff --git a/changelog/3.85/CHANGELOG-v3.85.md b/changelog/3.85/CHANGELOG-v3.85.md index 2c34adadd..046d0f399 100644 --- a/changelog/3.85/CHANGELOG-v3.85.md +++ b/changelog/3.85/CHANGELOG-v3.85.md @@ -27,6 +27,7 @@ * The console warnings when Audio files are missing/incorrect have been improved (thanks @samme) * The `requestVideoFrame` polyfill has been updated to the latest release, which should resolve some SSR framework issues. Fix #6776 (thanks @lantictac) * `ScaleManager` listeners includes checks for the `screen.orientation` object and adds/removes a `change` eventListener method to handle screen orientation changes on mobile devices. The `orientationchange` event is still maintained for backwards compatibility. Fix #6837 (thanks @rexrainbow) +* Updated MatterJS to 0.20.0 # Bug Fixes diff --git a/src/physics/matter-js/World.js b/src/physics/matter-js/World.js index 892e43523..ed2a48398 100644 --- a/src/physics/matter-js/World.js +++ b/src/physics/matter-js/World.js @@ -1479,12 +1479,15 @@ var World = new Class({ continue; } - for (var j = 0; j < pair.activeContacts.length; j++) + for (var j = 0; j < pair.contactCount; j++) { - var contact = pair.activeContacts[j]; + var contact = pair.contacts[j]; var vertex = contact.vertex; - - graphics.fillRect(vertex.x - 2, vertex.y - 2, 5, 5); + + if (vertex) + { + graphics.fillRect(vertex.x - 2, vertex.y - 2, 5, 5); + } } } @@ -1500,14 +1503,14 @@ var World = new Class({ } var collision = pair.collision; - var contacts = pair.activeContacts; + var contacts = pair.contacts; - if (contacts.length > 0) + if (pair.contactCount > 0) { var normalPosX = contacts[0].vertex.x; var normalPosY = contacts[0].vertex.y; - if (contacts.length === 2) + if (pair.contactCount === 2) { normalPosX = (contacts[0].vertex.x + contacts[1].vertex.x) / 2; normalPosY = (contacts[0].vertex.y + contacts[1].vertex.y) / 2; diff --git a/src/physics/matter-js/typedefs/MatterCollisionPair.js b/src/physics/matter-js/typedefs/MatterCollisionPair.js index da09c1f7f..c8c6eed5b 100644 --- a/src/physics/matter-js/typedefs/MatterCollisionPair.js +++ b/src/physics/matter-js/typedefs/MatterCollisionPair.js @@ -5,7 +5,7 @@ * @property {string} id - The unique auto-generated collision pair id. A combination of the body A and B IDs. * @property {MatterJS.BodyType} bodyA - A reference to the first body involved in the collision. * @property {MatterJS.BodyType} bodyB - A reference to the second body involved in the collision. - * @property {MatterJS.Vector[]} activeContacts - An array containing all of the active contacts between bodies A and B. + * @property {MatterJS.Vector[]} contacts - An array containing all of the active contacts between bodies A and B. * @property {number} separation - The amount of separation that occurred between bodies A and B. * @property {boolean} isActive - Is the collision still active or not? * @property {boolean} confirmedActive - Has Matter determined the collision are being active yet? diff --git a/types/matter.d.ts b/types/matter.d.ts index a01f4cc38..9a1ca2cd6 100644 --- a/types/matter.d.ts +++ b/types/matter.d.ts @@ -990,7 +990,7 @@ declare namespace MatterJS { bodyA: Body; bodyB: Body; contacts: any; - activeContacts: any; + contactCount: number; separation: number; isActive: boolean; timeCreated: number; @@ -1030,7 +1030,7 @@ declare namespace MatterJS { id: string; bodyA: Body; bodyB: Body; - activeContacts: Vector[]; + contacts: Vector[]; separation: number; isActive: boolean; confirmedActive: boolean; diff --git a/types/phaser.d.ts b/types/phaser.d.ts index 1df3c056f..b416946fc 100644 --- a/types/phaser.d.ts +++ b/types/phaser.d.ts @@ -75729,7 +75729,7 @@ declare namespace Phaser { /** * An array containing all of the active contacts between bodies A and B. */ - activeContacts: MatterJS.Vector[]; + contacts: MatterJS.Vector[]; /** * The amount of separation that occurred between bodies A and B. */