Setting a P2.Body from Static or Kinematic to Dynamic will now automatically adjust the Body.mass to be 1 (thanks @wayfu #2005)

This commit is contained in:
photonstorm 2015-08-20 11:19:16 +01:00
parent 994a7dae73
commit 55a7699381
2 changed files with 3 additions and 10 deletions

View file

@ -282,6 +282,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
* VideoStream.active = false is used if the browser supports it, otherwise it falls back to VideoStream.stop.
* Text can now accept `undefined` or `null` as the `text` argument in the constructor and will cast it as an empty string.
* Point.rotate uses a faster and simpler rotation function when no distance argument is specified.
* Setting a P2.Body from Static or Kinematic to Dynamic will now automatically adjust the Body.mass to be 1 (thanks @wayfu #2005)
### Bug Fixes

View file

@ -1434,11 +1434,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "static", {
else if (!value && this.data.type === Phaser.Physics.P2.Body.STATIC)
{
this.data.type = Phaser.Physics.P2.Body.DYNAMIC;
if (this.mass === 0)
{
this.mass = 1;
}
this.mass = 1;
}
}
@ -1462,11 +1458,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "dynamic", {
if (value && this.data.type !== Phaser.Physics.P2.Body.DYNAMIC)
{
this.data.type = Phaser.Physics.P2.Body.DYNAMIC;
if (this.mass === 0)
{
this.mass = 1;
}
this.mass = 1;
}
else if (!value && this.data.type === Phaser.Physics.P2.Body.DYNAMIC)
{