Don't reforce a forced position

This commit is contained in:
Richard Davey 2019-03-20 00:02:16 +00:00
parent 1e5c2ea0fc
commit 87e9f8e62d

View file

@ -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);