@@ -1146,16 +1146,24 @@ var Body = new Class({
11461146 // And finally we'll integrate the new position back to the Sprite in postUpdate
11471147 } ,
11481148
1149+ // Is this body moving OR can it be made to move?
1150+ // Return 'false' if it's immovable, otherwise 'true'
11491151 movingY : function ( )
11501152 {
1151- if ( this . sleeping || this . physicsType === CONST . STATIC_BODY )
1153+ if ( this . physicsType === CONST . STATIC_BODY || this . immovable )
11521154 {
1155+ // Static bodies don't move
11531156 return false ;
11541157 }
1158+ else if ( ! this . isWorldBlockedUp ( ) && ! this . isWorldBlockedDown ( ) )
1159+ {
1160+ // Non-blocked bodies, that aren't static, can always move
1161+ return true ;
1162+ }
11551163
11561164 var velocityY = this . velocity . y ;
11571165
1158- if ( ( velocityY <= 0 && this . isWorldBlockedUp ( ) ) || ( velocityY >= 0 && this . isWorldBlockedDown ( ) ) )
1166+ if ( ( velocityY < 0 && this . isWorldBlockedUp ( ) ) || ( velocityY > 0 && this . isWorldBlockedDown ( ) ) )
11591167 {
11601168 return false ;
11611169 }
@@ -1351,6 +1359,8 @@ var Body = new Class({
13511359
13521360 if ( this . forcePosition )
13531361 {
1362+ // console.log(this.world._frame, this.gameObject.name, 'forcePosition', this.y);
1363+
13541364 gameObject . x = this . x ;
13551365 gameObject . y = this . y ;
13561366
@@ -2182,8 +2192,11 @@ var Body = new Class({
21822192 this . setBlocker ( by ) ;
21832193
21842194 // if (forceY && !this.worldBlocked.up)
2185- if ( ! this . worldBlocked . up && this . velocity . y <= 0 )
2195+ // if (forceY && !this.worldBlocked.up && this.velocity.y <= 0)
2196+ if ( forceY && ! this . worldBlocked . up && this . velocity . y <= 0 )
21862197 {
2198+ console . log ( this . world . _frame , this . gameObject . name , 'setBlockedUp' ) ;
2199+
21872200 this . y = by . bottom ;
21882201 this . forcePosition = true ;
21892202
@@ -2207,9 +2220,20 @@ var Body = new Class({
22072220
22082221 this . setBlocker ( by ) ;
22092222
2223+ // leave out forceY and bodies settle on bounds properly, but get stuck when moving same direction
2224+ // add in forceY and bodies never get stuck together, but don't settle on bounds properly
2225+
2226+ // CheckOverlapY = calls this with 'false' for forcing Y
2227+ // GetOverlapY = calls this, setting 'true' for forcing Y
2228+ // SeparateY = calls this, not setting anything, so 'true' for forcing Y
2229+
22102230 // if (forceY && !this.worldBlocked.down)
2211- if ( ! this . worldBlocked . down && this . velocity . y >= 0 )
2231+ // if (forceY && !this.worldBlocked.down && this.velocity.y >= 0)
2232+ // if (!this.worldBlocked.down && this.velocity.y >= 0)
2233+ if ( forceY && ! this . worldBlocked . down && this . velocity . y >= 0 )
22122234 {
2235+ console . log ( this . world . _frame , this . gameObject . name , 'setBlockedDown' ) ;
2236+
22132237 this . bottom = by . y ;
22142238 this . forcePosition = true ;
22152239
0 commit comments