From e7fec396e180f3358f8aea6370a800d55f4288ae Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sun, 3 Jun 2018 21:17:33 +0100 Subject: [PATCH] If a Body collides with a Static Body it will now set the `blocked` properties accordingly --- CHANGELOG.md | 6 ++++++ src/physics/arcade/Body.js | 2 +- src/physics/arcade/GetOverlapX.js | 24 ++++++++++++++++++++++++ src/physics/arcade/GetOverlapY.js | 24 ++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95a1fffec..9d18ceefe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,11 +29,15 @@ * 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. * World.computeVelocity now uses the Body.useDamping property to perform either linear deceleration or damping on the Body. * World.updateMotion has changed to call the new `computeAngularVelocity` and `computeVelocity` methods. +* 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) +* 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) ### New Features * 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). * 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. +* The Update List has a new read-only property `length`, making it consistent with the Display List (thanks @samme) +* 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) ### Updates @@ -46,6 +50,8 @@ * Fixed an incorrect usage of `Math.abs()` in `Math.Quaternion.calculateW()` (thanks @qxzkjp). * Particle Emitter Managers can now be added to Containers (thanks @TadejZupancic) * 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. +* If you set Phaser to use a pre-existing Canvas element it is no longer re-added to the DOM (thanks @NQNStudios) +* The `TweenManager.getTweensOf` method has been fixed to remove a potential endless loop should multiple targets be passed in to it (thanks @cyantree) ## Version 3.9.0 - Yui - 24th May 2018 diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index acc516e57..415f8ea69 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -438,7 +438,7 @@ var Body = new Class({ * the game Asteroids) then you will get a far smoother and more visually correct deceleration * by using damping, avoiding the axis-drift that is prone with linear deceleration. * - * If you enable this property then you should use far smaller `drag` values with linear, as + * If you enable this property then you should use far smaller `drag` values than with linear, as * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. * diff --git a/src/physics/arcade/GetOverlapX.js b/src/physics/arcade/GetOverlapX.js index 8a746060e..a58e73e58 100644 --- a/src/physics/arcade/GetOverlapX.js +++ b/src/physics/arcade/GetOverlapX.js @@ -4,6 +4,8 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var CONST = require('./const'); + /** * [description] * @@ -41,8 +43,19 @@ var GetOverlapX = function (body1, body2, overlapOnly, bias) { body1.touching.none = false; body1.touching.right = true; + body2.touching.none = false; body2.touching.left = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.right = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.left = true; + } } } else if (body1._dx < body2._dx) @@ -58,8 +71,19 @@ var GetOverlapX = function (body1, body2, overlapOnly, bias) { body1.touching.none = false; body1.touching.left = true; + body2.touching.none = false; body2.touching.right = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.left = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.right = true; + } } } diff --git a/src/physics/arcade/GetOverlapY.js b/src/physics/arcade/GetOverlapY.js index 37e91306f..6ab13281f 100644 --- a/src/physics/arcade/GetOverlapY.js +++ b/src/physics/arcade/GetOverlapY.js @@ -4,6 +4,8 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var CONST = require('./const'); + /** * [description] * @@ -41,8 +43,19 @@ var GetOverlapY = function (body1, body2, overlapOnly, bias) { body1.touching.none = false; body1.touching.down = true; + body2.touching.none = false; body2.touching.up = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.down = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.up = true; + } } } else if (body1._dy < body2._dy) @@ -58,8 +71,19 @@ var GetOverlapY = function (body1, body2, overlapOnly, bias) { body1.touching.none = false; body1.touching.up = true; + body2.touching.none = false; body2.touching.down = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.up = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.down = true; + } } }