From f165acfe5f5c87604d26a4e39668257d9ae3db14 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 9 Nov 2017 17:10:33 +0000 Subject: [PATCH] Colliders can now be toggled from active to inactive. Collider.destroy added (but needs doing in World too). --- v3/src/physics/arcade/Collider.js | 16 ++++++++++++++++ v3/src/physics/arcade/World.js | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/v3/src/physics/arcade/Collider.js b/v3/src/physics/arcade/Collider.js index ec85d52b1..1f92bf840 100644 --- a/v3/src/physics/arcade/Collider.js +++ b/v3/src/physics/arcade/Collider.js @@ -10,6 +10,8 @@ var Collider = new Class({ { this.world = world; + this.active = true; + this.overlapOnly = overlapOnly; this.object1 = object1; @@ -30,6 +32,20 @@ var Collider = new Class({ this.callbackContext, this.overlapOnly ); + }, + + destroy: function () + { + this.world.removeCollider(this); + + this.world = null; + + this.object1 = null; + this.object2 = null; + + this.collideCallback = null; + this.processCallback = null; + this.callbackContext = null; } }); diff --git a/v3/src/physics/arcade/World.js b/v3/src/physics/arcade/World.js index 7e7e63ac1..20e303edc 100644 --- a/v3/src/physics/arcade/World.js +++ b/v3/src/physics/arcade/World.js @@ -249,6 +249,11 @@ var World = new Class({ return collider; }, + removeCollider: function (collider) + { + // TODO + }, + update: function (time, delta) { if (this.isPaused || this.bodies.size === 0) @@ -286,7 +291,12 @@ var World = new Class({ for (i = 0; i < this.colliders.length; i++) { - this.colliders[i].update(); + var collider = this.colliders[i]; + + if (collider.active) + { + collider.update(); + } } },