The Arcade Physics Body.speed property is now set whenever you set the velocity via setVelocity or setVelocityX or setVelocityY which stops the body velocity being reset to zero if useDamping is enabled. Fix #3888

This commit is contained in:
Richard Davey 2018-08-08 17:31:22 +01:00
parent fe2ddcf934
commit 4bdb0de312
3 changed files with 16 additions and 3 deletions

View file

@ -179,6 +179,7 @@ Setting the `resolution` property in the Game Config to a value other than 1 wou
* Matter.js has received a tiny update that prevents `collisionEnd` from triggering many times when it should only trigger once (thanks @mikewesthad)
* Graphics objects couldn't be set to be ignored by Cameras. Now every renderable Game Object can be ignored by a Camera, either directly or via a Container. The exception are Groups because they don't render and are non-exclusive parents.
* The Tilemap Culling function now uses the Tilemap tile dimensions for its bounds calculations, instead of the layer tile sizes, as they two don't have to match and it's the underlying grid size that takes precedence when calculating visible tiles. Fix #3893 (thanks @Zax37)
* The Arcade Physics `Body.speed` property is now set whenever you set the velocity via `setVelocity` or `setVelocityX` or `setVelocityY` which stops the body velocity being reset to zero if `useDamping` is enabled. Fix #3888 (thanks @samme)
### Examples, Documentation and TypeScript

View file

@ -1455,6 +1455,8 @@ var Body = new Class({
{
this.velocity.set(x, y);
this.speed = Math.sqrt(x * x + y * y);
return this;
},
@ -1472,6 +1474,11 @@ var Body = new Class({
{
this.velocity.x = value;
var vx = value;
var vy = this.velocity.y;
this.speed = Math.sqrt(vx * vx + vy * vy);
return this;
},
@ -1489,6 +1496,11 @@ var Body = new Class({
{
this.velocity.y = value;
var vx = this.velocity.x;
var vy = value;
this.speed = Math.sqrt(vx * vx + vy * vy);
return this;
},

View file

@ -25,7 +25,7 @@ var Velocity = {
*/
setVelocity: function (x, y)
{
this.body.velocity.set(x, y);
this.body.setVelocity(x, y);
return this;
},
@ -42,7 +42,7 @@ var Velocity = {
*/
setVelocityX: function (x)
{
this.body.velocity.x = x;
this.body.setVelocityX(x);
return this;
},
@ -59,7 +59,7 @@ var Velocity = {
*/
setVelocityY: function (y)
{
this.body.velocity.y = y;
this.body.setVelocityY(y);
return this;
},