From 0ee93393e32cdce9cf565734b56d36bf439a9c54 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 9 Nov 2017 17:03:21 +0000 Subject: [PATCH] CollideObjects now handles the total setting and returning. --- v3/src/physics/arcade/inc/Collide.js | 6 +----- v3/src/physics/arcade/inc/CollideObjects.js | 4 ++++ v3/src/physics/arcade/inc/Overlap.js | 6 +----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/v3/src/physics/arcade/inc/Collide.js b/v3/src/physics/arcade/inc/Collide.js index 39c47820f..387ed75bf 100644 --- a/v3/src/physics/arcade/inc/Collide.js +++ b/v3/src/physics/arcade/inc/Collide.js @@ -4,11 +4,7 @@ var Collide = function (object1, object2, collideCallback, processCallback, call if (processCallback === undefined) { processCallback = null; } if (callbackContext === undefined) { callbackContext = collideCallback; } - this._total = 0; - - this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); - - return (this._total > 0); + return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); }; module.exports = Collide; diff --git a/v3/src/physics/arcade/inc/CollideObjects.js b/v3/src/physics/arcade/inc/CollideObjects.js index 2419621b8..0dd1792c2 100644 --- a/v3/src/physics/arcade/inc/CollideObjects.js +++ b/v3/src/physics/arcade/inc/CollideObjects.js @@ -4,6 +4,8 @@ var CollideObjects = function (object1, object2, collideCallback, processCallbac var object1isArray = Array.isArray(object1); var object2isArray = Array.isArray(object2); + this._total = 0; + if (!object1isArray && !object2isArray) { // Neither of them are arrays - do this first as it's the most common use-case @@ -36,6 +38,8 @@ var CollideObjects = function (object1, object2, collideCallback, processCallbac } } } + + return (this._total > 0); }; module.exports = CollideObjects; diff --git a/v3/src/physics/arcade/inc/Overlap.js b/v3/src/physics/arcade/inc/Overlap.js index 8265f9f91..122ad991c 100644 --- a/v3/src/physics/arcade/inc/Overlap.js +++ b/v3/src/physics/arcade/inc/Overlap.js @@ -4,11 +4,7 @@ var Overlap = function (object1, object2, overlapCallback, processCallback, call if (processCallback === undefined) { processCallback = null; } if (callbackContext === undefined) { callbackContext = overlapCallback; } - this._total = 0; - - this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); - - return (this._total > 0); + return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); }; module.exports = Overlap;