From 14d3f6b35c73aa5c77f01c84ae38806c8e2f3c55 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 29 Aug 2018 16:35:13 +0100 Subject: [PATCH] Calling Arcade Physics `collide` during an `update` method wouldn't inject the results back into the Body parent, causing the bodies to carry on moving. Using Colliders worked, but manually checking did not. Now, both methods work. Fix #3777 --- src/physics/arcade/StaticBody.js | 10 ++++++++++ src/physics/arcade/World.js | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/physics/arcade/StaticBody.js b/src/physics/arcade/StaticBody.js index 2522309140..ad224593cc 100644 --- a/src/physics/arcade/StaticBody.js +++ b/src/physics/arcade/StaticBody.js @@ -666,6 +666,16 @@ var StaticBody = new Class({ return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); }, + /** + * NOOP + * + * @method Phaser.Physics.Arcade.StaticBody#postUpdate + * @since 3.12.0 + */ + postUpdate: function () + { + }, + /** * [description] * diff --git a/src/physics/arcade/World.js b/src/physics/arcade/World.js index fa4cde5960..59c70b7aea 100644 --- a/src/physics/arcade/World.js +++ b/src/physics/arcade/World.js @@ -1457,9 +1457,15 @@ var World = new Class({ { this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); } - else if (body1.onCollide || body2.onCollide) + else { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + body1.postUpdate(); + body2.postUpdate(); + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } } }