Skip to content

Commit 87e9f8e

Browse files
committed
Don't reforce a forced position
1 parent 1e5c2ea commit 87e9f8e

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

src/physics/arcade/Body.js

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,8 +1299,9 @@ var Body = new Class({
12991299

13001300
var worldBlocked = this.worldBlocked;
13011301

1302-
// if (Math.abs(dy) < 1 && this.isBlockedUp())
1303-
if (Math.abs(dy) < 1 && !this.worldBlocked.none)
1302+
// else if (this._sleep > 0 && !this.worldBlocked.up && !this.worldBlocked.down)
1303+
1304+
if (Math.abs(dy) < 1 && this.isBlocked())
13041305
{
13051306
if (this._sleep < this.sleepIterations)
13061307
{
@@ -1312,8 +1313,7 @@ var Body = new Class({
13121313
}
13131314
}
13141315
}
1315-
// else if (this._sleep > 0 && !this.isBlockedY())
1316-
else if (this._sleep > 0 && !this.worldBlocked.up && !this.worldBlocked.down)
1316+
else if (this._sleep > 0 && !this.isBlockedY())
13171317
{
13181318
// Waking up? Do it progressively, not instantly, to ensure it isn't just a step fluctuation
13191319
this._sleep *= 0.8;
@@ -2066,6 +2066,17 @@ var Body = new Class({
20662066

20672067
this.setBlocker(by);
20682068

2069+
if (!this.forcePosition)
2070+
{
2071+
this.y = by.bottom;
2072+
this.forcePosition = true;
2073+
2074+
if (this.bounce.y === 0)
2075+
{
2076+
this.velocity.y = 0;
2077+
}
2078+
}
2079+
20692080
return this;
20702081
},
20712082

@@ -2078,6 +2089,17 @@ var Body = new Class({
20782089

20792090
this.setBlocker(by);
20802091

2092+
if (!this.forcePosition)
2093+
{
2094+
this.bottom = by.y;
2095+
this.forcePosition = true;
2096+
2097+
if (this.bounce.y === 0)
2098+
{
2099+
this.velocity.y = 0;
2100+
}
2101+
}
2102+
20812103
return this;
20822104
},
20832105

@@ -2196,6 +2218,11 @@ var Body = new Class({
21962218
return amount;
21972219
},
21982220

2221+
isBlocked: function ()
2222+
{
2223+
return (!this.blocked.none || !this.worldBlocked.none);
2224+
},
2225+
21992226
isBlockedUp: function ()
22002227
{
22012228
return (this.blocked.up || this.worldBlocked.up);

0 commit comments

Comments
 (0)