Skip to content

Commit

Permalink
The property checkCollision.none in the ArcadePhysics.Body class wa…
Browse files Browse the repository at this point in the history
…s 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)
  • Loading branch information
photonstorm committed Jul 23, 2016
1 parent ab739bd commit 6947057
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* Group.getRandomExists will return a random child from the Group that has exists set to true.
* 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.
* Group.iterate has a new `returnType`: `RETURN_ALL`. This allows you to return all children that pass the iteration test in an array.
* 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)

### Updates

Expand All @@ -326,7 +327,6 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* 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.
* 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.
* 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.
* 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)

### Bug Fixes

Expand Down
4 changes: 3 additions & 1 deletion src/physics/arcade/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,11 @@ Phaser.Physics.Arcade.Body = function (sprite) {
/**
* Set the checkCollision properties to control which directions collision is processed for this Body.
* For example checkCollision.up = false means it won't collide when the collision happened while moving up.
* If you need to disable a Body entirely, use `body.enable = false`, this will also disable motion.
* If you need to disable just collision and/or overlap checks, but retain motion, set `checkCollision.none = true`.
* @property {object} checkCollision - An object containing allowed collision.
*/
this.checkCollision = { any: true, up: true, down: true, left: true, right: true };
this.checkCollision = { none: false, any: true, up: true, down: true, left: true, right: true };

/**
* This object is populated with boolean values when the Body collides with another.
Expand Down
7 changes: 6 additions & 1 deletion src/physics/arcade/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,12 @@ Phaser.Physics.Arcade.prototype = {
*/
separate: function (body1, body2, processCallback, callbackContext, overlapOnly) {

if (!body1.enable || !body2.enable || !this.intersects(body1, body2))
if (
!body1.enable ||
!body2.enable ||
body1.checkCollision.none ||
body2.checkCollision.none ||
!this.intersects(body1, body2))
{
return false;
}
Expand Down
1 change: 1 addition & 0 deletions typescript/phaser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3076,6 +3076,7 @@ declare module Phaser {

class FaceChoices {

none: boolean;
any: boolean;
up: boolean;
down: boolean;
Expand Down

0 comments on commit 6947057

Please sign in to comment.