mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 23:20:59 +00:00
Don't reforce a forced position
This commit is contained in:
parent
1e5c2ea0fc
commit
87e9f8e62d
1 changed files with 31 additions and 4 deletions
|
@ -1299,8 +1299,9 @@ var Body = new Class({
|
|||
|
||||
var worldBlocked = this.worldBlocked;
|
||||
|
||||
// if (Math.abs(dy) < 1 && this.isBlockedUp())
|
||||
if (Math.abs(dy) < 1 && !this.worldBlocked.none)
|
||||
// else if (this._sleep > 0 && !this.worldBlocked.up && !this.worldBlocked.down)
|
||||
|
||||
if (Math.abs(dy) < 1 && this.isBlocked())
|
||||
{
|
||||
if (this._sleep < this.sleepIterations)
|
||||
{
|
||||
|
@ -1312,8 +1313,7 @@ var Body = new Class({
|
|||
}
|
||||
}
|
||||
}
|
||||
// else if (this._sleep > 0 && !this.isBlockedY())
|
||||
else if (this._sleep > 0 && !this.worldBlocked.up && !this.worldBlocked.down)
|
||||
else if (this._sleep > 0 && !this.isBlockedY())
|
||||
{
|
||||
// Waking up? Do it progressively, not instantly, to ensure it isn't just a step fluctuation
|
||||
this._sleep *= 0.8;
|
||||
|
@ -2066,6 +2066,17 @@ var Body = new Class({
|
|||
|
||||
this.setBlocker(by);
|
||||
|
||||
if (!this.forcePosition)
|
||||
{
|
||||
this.y = by.bottom;
|
||||
this.forcePosition = true;
|
||||
|
||||
if (this.bounce.y === 0)
|
||||
{
|
||||
this.velocity.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -2078,6 +2089,17 @@ var Body = new Class({
|
|||
|
||||
this.setBlocker(by);
|
||||
|
||||
if (!this.forcePosition)
|
||||
{
|
||||
this.bottom = by.y;
|
||||
this.forcePosition = true;
|
||||
|
||||
if (this.bounce.y === 0)
|
||||
{
|
||||
this.velocity.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -2196,6 +2218,11 @@ var Body = new Class({
|
|||
return amount;
|
||||
},
|
||||
|
||||
isBlocked: function ()
|
||||
{
|
||||
return (!this.blocked.none || !this.worldBlocked.none);
|
||||
},
|
||||
|
||||
isBlockedUp: function ()
|
||||
{
|
||||
return (this.blocked.up || this.worldBlocked.up);
|
||||
|
|
Loading…
Reference in a new issue