Skip to content

Commit e7fec39

Browse files
committed
If a Body collides with a Static Body it will now set the blocked properties accordingly
1 parent e3e4130 commit e7fec39

4 files changed

Lines changed: 55 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@
2929
* World.computeVelocity has been recoded to use Fuzzy Greater Than and Less Than calls when factoring in drag to a previously accelerated body. Using a fuzzy epsilon allows us to mitigate the ping-pong issue, where a decelerating body would constantly flip between a small negative and positive velocity value and never come to an actual rest.
3030
* World.computeVelocity now uses the Body.useDamping property to perform either linear deceleration or damping on the Body.
3131
* World.updateMotion has changed to call the new `computeAngularVelocity` and `computeVelocity` methods.
32+
* Bodies set to bounce would eventually run out of velocity and stop. This has been fixed as part of the refactoring of the time step and velocity computation updates. Fix #3593 (thanks @helmi77)
33+
* If a Body collides with a Static Body it will now set the `blocked` properties accordingly (before it only set the `touching` properties.) This means you can now use checks like `Body.onFloor()` when traversing static bodies (thanks @fariazz)
3234

3335
### New Features
3436

3537
* RenderTexture.resize will allow you to resize the underlying Render Texture to the new dimensions given. Doing this also clears the Render Texture at the same time (thanks @saqsun).
3638
* Rectangle.RandomOutside is a new function that takes two Rectangles, `outer` and `inner`, and returns a random point that falls within the outer rectangle but is always outside of the inner rectangle.
39+
* The Update List has a new read-only property `length`, making it consistent with the Display List (thanks @samme)
40+
* The 2D Camera class has two new read-only properties `centerX` and `centerY` which return the coordinates of the center of the viewport, relative to the canvas (thanks @samme)
3741

3842
### Updates
3943

@@ -46,6 +50,8 @@
4650
* Fixed an incorrect usage of `Math.abs()` in `Math.Quaternion.calculateW()` (thanks @qxzkjp).
4751
* Particle Emitter Managers can now be added to Containers (thanks @TadejZupancic)
4852
* Fixed a method signature issue with the Animation component's `remove()` handler when `Animation`s are removed from the `AnimationManager`. This prevented removed animations from stopping correctly.
53+
* If you set Phaser to use a pre-existing Canvas element it is no longer re-added to the DOM (thanks @NQNStudios)
54+
* The `TweenManager.getTweensOf` method has been fixed to remove a potential endless loop should multiple targets be passed in to it (thanks @cyantree)
4955

5056
## Version 3.9.0 - Yui - 24th May 2018
5157

src/physics/arcade/Body.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ var Body = new Class({
438438
* the game Asteroids) then you will get a far smoother and more visually correct deceleration
439439
* by using damping, avoiding the axis-drift that is prone with linear deceleration.
440440
*
441-
* If you enable this property then you should use far smaller `drag` values with linear, as
441+
* If you enable this property then you should use far smaller `drag` values than with linear, as
442442
* they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow
443443
* deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately.
444444
*

src/physics/arcade/GetOverlapX.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7+
var CONST = require('./const');
8+
79
/**
810
* [description]
911
*
@@ -41,8 +43,19 @@ var GetOverlapX = function (body1, body2, overlapOnly, bias)
4143
{
4244
body1.touching.none = false;
4345
body1.touching.right = true;
46+
4447
body2.touching.none = false;
4548
body2.touching.left = true;
49+
50+
if (body2.physicsType === CONST.STATIC_BODY)
51+
{
52+
body1.blocked.right = true;
53+
}
54+
55+
if (body1.physicsType === CONST.STATIC_BODY)
56+
{
57+
body2.blocked.left = true;
58+
}
4659
}
4760
}
4861
else if (body1._dx < body2._dx)
@@ -58,8 +71,19 @@ var GetOverlapX = function (body1, body2, overlapOnly, bias)
5871
{
5972
body1.touching.none = false;
6073
body1.touching.left = true;
74+
6175
body2.touching.none = false;
6276
body2.touching.right = true;
77+
78+
if (body2.physicsType === CONST.STATIC_BODY)
79+
{
80+
body1.blocked.left = true;
81+
}
82+
83+
if (body1.physicsType === CONST.STATIC_BODY)
84+
{
85+
body2.blocked.right = true;
86+
}
6387
}
6488
}
6589

src/physics/arcade/GetOverlapY.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7+
var CONST = require('./const');
8+
79
/**
810
* [description]
911
*
@@ -41,8 +43,19 @@ var GetOverlapY = function (body1, body2, overlapOnly, bias)
4143
{
4244
body1.touching.none = false;
4345
body1.touching.down = true;
46+
4447
body2.touching.none = false;
4548
body2.touching.up = true;
49+
50+
if (body2.physicsType === CONST.STATIC_BODY)
51+
{
52+
body1.blocked.down = true;
53+
}
54+
55+
if (body1.physicsType === CONST.STATIC_BODY)
56+
{
57+
body2.blocked.up = true;
58+
}
4659
}
4760
}
4861
else if (body1._dy < body2._dy)
@@ -58,8 +71,19 @@ var GetOverlapY = function (body1, body2, overlapOnly, bias)
5871
{
5972
body1.touching.none = false;
6073
body1.touching.up = true;
74+
6175
body2.touching.none = false;
6276
body2.touching.down = true;
77+
78+
if (body2.physicsType === CONST.STATIC_BODY)
79+
{
80+
body1.blocked.up = true;
81+
}
82+
83+
if (body1.physicsType === CONST.STATIC_BODY)
84+
{
85+
body2.blocked.down = true;
86+
}
6387
}
6488
}
6589

0 commit comments

Comments
 (0)