@@ -950,18 +950,18 @@ var Body = new Class({
950950 // Updates the transform values
951951 this . updateBounds ( ) ;
952952
953- // Reset deltas (world bounds checks have no effect on this)
954- this . prev . x = this . x ;
955- this . prev . y = this . y ;
956- this . preRotation = this . rotation ;
957-
958953 var parent = this . transform ;
959954
960955 this . x = parent . x + parent . scaleX * ( this . offset . x - parent . displayOriginX ) ;
961956 this . y = parent . y + parent . scaleY * ( this . offset . y - parent . displayOriginY ) ;
962957
963958 this . rotation = parent . rotation ;
964959
960+ // Reset deltas (world bounds checks have no effect on this)
961+ this . prev . x = this . x ;
962+ this . prev . y = this . y ;
963+ this . preRotation = this . rotation ;
964+
965965 if ( this . collideWorldBounds )
966966 {
967967 this . checkWorldBounds ( ) ;
@@ -1097,8 +1097,6 @@ var Body = new Class({
10971097
10981098 if ( this . forcePosition > 0 )
10991099 {
1100- // console.log(this.world._frame, this.gameObject.name, 'forcePosition. Type: ', this.forcePosition);
1101-
11021100 var snapX = this . x ;
11031101 var snapY = this . y ;
11041102
@@ -1120,9 +1118,9 @@ var Body = new Class({
11201118 snapX = this . snapTo . x - this . width ;
11211119 break ;
11221120 }
1123-
1124- gameObject . x = snapX ;
1125- gameObject . y = snapY ;
1121+
1122+ gameObject . x += ( snapX - this . prev . x ) ;
1123+ gameObject . y += ( snapY - this . prev . y ) ;
11261124
11271125 dx = 0 ;
11281126 dy = 0 ;
@@ -1196,23 +1194,22 @@ var Body = new Class({
11961194 if ( worldBlocked . up )
11971195 {
11981196 this . y = worldBounds . y ;
1199- this . forcePosition = 5 ;
12001197 }
12011198 else if ( worldBlocked . down )
12021199 {
12031200 this . bottom = worldBounds . bottom ;
1204- this . forcePosition = 5 ;
12051201 }
1206- else if ( worldBlocked . left )
1202+
1203+ if ( worldBlocked . left )
12071204 {
12081205 this . x = worldBounds . x ;
1209- this . forcePosition = 5 ;
12101206 }
12111207 else if ( worldBlocked . right )
12121208 {
12131209 this . right = worldBounds . right ;
1214- this . forcePosition = 5 ;
12151210 }
1211+
1212+ this . forcePosition = 5 ;
12161213 }
12171214 else if ( ! blocked . none )
12181215 {
@@ -1356,7 +1353,6 @@ var Body = new Class({
13561353 // Static or Immovable
13571354 // Under direct movement control
13581355 // Has bounce and is moving left but is blocked right, or is moving right and is blocked left
1359- // Isn't moving faster than minVelocity, once factoring in gravity
13601356 // Otherwise, return true
13611357 canMoveX : function ( )
13621358 {
@@ -1374,16 +1370,13 @@ var Body = new Class({
13741370 return false ;
13751371 }
13761372
1377- var actualVelocityX = Math . abs ( velocityX ) - Math . abs ( this . _gx ) ;
1378-
1379- return ( actualVelocityX > this . minVelocity . x ) ;
1373+ return true ;
13801374 } ,
13811375
13821376 // Return false if this body is:
13831377 // Static or Immovable
13841378 // Under direct movement control
13851379 // Has bounce and is moving up but is blocked down, or is moving down and is blocked up
1386- // Isn't moving faster than minVelocity, once factoring in gravity
13871380 // Otherwise, return true
13881381 canMoveY : function ( )
13891382 {
@@ -1401,9 +1394,7 @@ var Body = new Class({
14011394 return false ;
14021395 }
14031396
1404- var actualVelocityY = Math . abs ( velocityY ) - Math . abs ( this . _gy ) ;
1405-
1406- return ( actualVelocityY > this . minVelocity . y ) ;
1397+ return true ;
14071398 } ,
14081399
14091400 // Return true if body can be repositioned after this call, otherwise return false to stop positioning in the update
@@ -1663,10 +1654,10 @@ var Body = new Class({
16631654
16641655 // console.log(this.world._frame, 'slept by checkSleep');
16651656
1666- var gameObject = this . gameObject ;
1657+ // var gameObject = this.gameObject;
16671658
1668- gameObject . x = this . x ;
1669- gameObject . y = this . y ;
1659+ // gameObject.x = this.x;
1660+ // gameObject.y = this.y;
16701661 }
16711662 }
16721663 }
@@ -1683,7 +1674,7 @@ var Body = new Class({
16831674
16841675 if ( this . _sleep <= 0 )
16851676 {
1686- console . log ( 'body woken from postUpdate' , dy ) ;
1677+ // console.log('body woken from postUpdate', dy);
16871678 this . wake ( ) ;
16881679 }
16891680 }
@@ -2645,8 +2636,6 @@ var Body = new Class({
26452636 this . y = worldBounds . y ;
26462637
26472638 this . forcePosition = 5 ;
2648-
2649- // console.log(this.world._frame, this.gameObject.name, 'world blocked up + position', this.y);
26502639 }
26512640
26522641 return this ;
@@ -2671,8 +2660,6 @@ var Body = new Class({
26712660 this . bottom = worldBounds . bottom ;
26722661
26732662 this . forcePosition = 5 ;
2674-
2675- // console.log(this.world._frame, this.gameObject.name, 'world blocked down + position', this.y);
26762663 }
26772664
26782665 return this ;
@@ -2697,8 +2684,6 @@ var Body = new Class({
26972684 this . x = worldBounds . x ;
26982685
26992686 this . forcePosition = 5 ;
2700-
2701- // console.log(this.world._frame, this.gameObject.name, 'world blocked up + position', this.y);
27022687 }
27032688
27042689 return this ;
@@ -2723,8 +2708,6 @@ var Body = new Class({
27232708 this . right = worldBounds . right ;
27242709
27252710 this . forcePosition = 5 ;
2726-
2727- // console.log(this.world._frame, this.gameObject.name, 'world blocked up + position', this.y);
27282711 }
27292712
27302713 return this ;
0 commit comments