@@ -314,7 +314,7 @@ var Body = new Class({
314314
315315 this . _sleep = 0 ;
316316
317- this . sleepIterations = 60 ;
317+ this . sleepIterations = 60 * world . positionIterations ;
318318
319319 // 0 = none, 1 = soft block, 2 = hard block
320320 this . forcePosition = 0 ;
@@ -1063,7 +1063,7 @@ var Body = new Class({
10631063 this . checkWorldRebound ( ) ;
10641064 }
10651065
1066- if ( this . forcePosition !== 5 )
1066+ if ( this . forcePosition < 5 )
10671067 {
10681068 position . x += this . getMoveX ( velocity . x * delta ) ;
10691069 position . y += this . getMoveY ( velocity . y * delta ) ;
@@ -1174,8 +1174,8 @@ var Body = new Class({
11741174 }
11751175 else if ( ! this . sleeping )
11761176 {
1177- gameObject . x += dx ;
1178- gameObject . y += dy ;
1177+ gameObject . x += dx / this . world . positionIterations ;
1178+ gameObject . y += dy / this . world . positionIterations ;
11791179
11801180 if ( this . allowRotation )
11811181 {
@@ -2292,22 +2292,22 @@ var Body = new Class({
22922292 {
22932293 ArrayAdd ( this . blockers . up , collisionInfo ) ;
22942294 }
2295- else
2295+ else if ( body2 . isWorldBlockedUp ( ) )
22962296 {
2297- if ( body2 . isWorldBlockedUp ( ) )
2298- {
2299- this . setHardBlockedUp ( ) ;
2300- }
2297+ this . setHardBlockedUp ( ) ;
2298+
2299+ this . forcePosition = 6 ;
2300+
2301+ this . y = body2 . bottom ;
23012302 }
23022303
23032304 // We don't reposition this body if it's already blocked on a face
2304- if ( this . forcePosition === 5 || this . worldBlocked . down || this . worldBlocked . up )
2305+ if ( this . forcePosition === 5 || this . isWorldBlockedUp ( ) || this . isWorldBlockedDown ( ) )
23052306 {
23062307 return this ;
23072308 }
23082309
2309- // if (body2 && !collisionInfo.set)
2310- if ( body2 )
2310+ if ( body2 && ! collisionInfo . set )
23112311 {
23122312 console . log ( this . gameObject . name , 'setBlockedUp' , body2 . bottom ) ;
23132313
@@ -2317,7 +2317,7 @@ var Body = new Class({
23172317
23182318 this . forcePosition = 1 ;
23192319
2320- // collisionInfo.set = true;
2320+ collisionInfo . set = true ;
23212321 }
23222322 }
23232323
@@ -2337,22 +2337,22 @@ var Body = new Class({
23372337 {
23382338 ArrayAdd ( this . blockers . down , collisionInfo ) ;
23392339 }
2340- else
2340+ else if ( body2 . isWorldBlockedDown ( ) )
23412341 {
2342- if ( body2 . isWorldBlockedDown ( ) )
2343- {
2344- this . setHardBlockedDown ( ) ;
2345- }
2342+ this . setHardBlockedDown ( ) ;
2343+
2344+ this . forcePosition = 7 ;
2345+
2346+ this . bottom = body2 . y ;
23462347 }
23472348
23482349 // We don't reposition this body if it's already blocked on a face
2349- if ( this . forcePosition === 5 || this . worldBlocked . down || this . worldBlocked . up )
2350+ if ( this . forcePosition === 5 || this . isWorldBlockedUp ( ) || this . isWorldBlockedDown ( ) )
23502351 {
23512352 return this ;
23522353 }
23532354
2354- // if (body2 && !collisionInfo.set)
2355- if ( body2 )
2355+ if ( body2 && ! collisionInfo . set )
23562356 {
23572357 console . log ( this . gameObject . name , 'setBlockedDown' , body2 . y ) ;
23582358
@@ -2362,7 +2362,7 @@ var Body = new Class({
23622362
23632363 this . forcePosition = 2 ;
23642364
2365- // collisionInfo.set = true;
2365+ collisionInfo . set = true ;
23662366 }
23672367 }
23682368
0 commit comments