Skip to content

Commit 6947057

Browse files
committed
The property checkCollision.none in the ArcadePhysics.Body class was available, but never used internally. It is now used and checked by the separate method. By setting checkCollision.none = true you can disable all collision and overlap checks on a Body, but still retain its motion updates (thanks @samme phaserjs#2661)
1 parent ab739bd commit 6947057

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
313313
* Group.getRandomExists will return a random child from the Group that has exists set to true.
314314
* Group.getAll will return all children in the Group, or a section of the Group, with the optional ability to test if the child has a property matching the given value or not.
315315
* Group.iterate has a new `returnType`: `RETURN_ALL`. This allows you to return all children that pass the iteration test in an array.
316+
* The property `checkCollision.none` in the ArcadePhysics.Body class was available, but never used internally. It is now used and checked by the `separate` method. By setting `checkCollision.none = true` you can disable all collision and overlap checks on a Body, but still retain its motion updates (thanks @samme #2661)
316317

317318
### Updates
318319

@@ -326,7 +327,6 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
326327
* The Loader.headers object has a new property `requestedWith`. By default this is set to `false`, but it can be used to set the `X-Requested-With` header to `XMLHttpRequest` (or any other value you need). To enable this do `this.load.headers.requestedWith = 'XMLHttpRequest'` before adding anything to the Loader.
327328
* ScaleManager.hasPhaserSetFullScreen is a new boolean that identifies if the browser is in full screen mode or not, and if Phaser was the one that requested it. As it's possible to enter full screen mode outside of Phaser, and it then gets confused about what bounding parent to use.
328329
* Phaser.Tileset has a new property `lastgid` which is populated automatically by the TilemapParser when importing Tiled map data, or can be set manually if building your own tileset.
329-
* The property `checkCollision.none` has been removed from the ArcadePhysics.Body class. It was never used internally, so lead to confusion about its use. To disable a body, use `body.enable = false` (thanks @samme #2661)
330330

331331
### Bug Fixes
332332

src/physics/arcade/Body.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,11 @@ Phaser.Physics.Arcade.Body = function (sprite) {
363363
/**
364364
* Set the checkCollision properties to control which directions collision is processed for this Body.
365365
* For example checkCollision.up = false means it won't collide when the collision happened while moving up.
366+
* If you need to disable a Body entirely, use `body.enable = false`, this will also disable motion.
367+
* If you need to disable just collision and/or overlap checks, but retain motion, set `checkCollision.none = true`.
366368
* @property {object} checkCollision - An object containing allowed collision.
367369
*/
368-
this.checkCollision = { any: true, up: true, down: true, left: true, right: true };
370+
this.checkCollision = { none: false, any: true, up: true, down: true, left: true, right: true };
369371

370372
/**
371373
* This object is populated with boolean values when the Body collides with another.

src/physics/arcade/World.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,12 @@ Phaser.Physics.Arcade.prototype = {
947947
*/
948948
separate: function (body1, body2, processCallback, callbackContext, overlapOnly) {
949949

950-
if (!body1.enable || !body2.enable || !this.intersects(body1, body2))
950+
if (
951+
!body1.enable ||
952+
!body2.enable ||
953+
body1.checkCollision.none ||
954+
body2.checkCollision.none ||
955+
!this.intersects(body1, body2))
951956
{
952957
return false;
953958
}

typescript/phaser.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,7 @@ declare module Phaser {
30763076

30773077
class FaceChoices {
30783078

3079+
none: boolean;
30793080
any: boolean;
30803081
up: boolean;
30813082
down: boolean;

0 commit comments

Comments
 (0)