@@ -947,6 +947,11 @@ var Body = new Class({
947947 this . embedded = false ;
948948 this . forcePosition = 0 ;
949949
950+ this . checkSleep ( this . _dx , this . _dy ) ;
951+
952+ this . _sleepX = this . x ;
953+ this . _sleepY = this . y ;
954+
950955 // Updates the transform values
951956 this . updateBounds ( ) ;
952957
@@ -1142,8 +1147,6 @@ var Body = new Class({
11421147 this . _dx = dx ;
11431148 this . _dy = dy ;
11441149
1145- this . checkSleep ( dx , dy ) ;
1146-
11471150 // Store collision flags
11481151 var wasTouching = this . wasTouching ;
11491152 var touching = this . touching ;
@@ -1161,7 +1164,7 @@ var Body = new Class({
11611164 {
11621165 this . sleeping = true ;
11631166
1164- // console.log(this.gameObject.name, 'put to sleep on frame', this.world._frame, 'force?', forceY, 'at', this.y );
1167+ console . log ( this . gameObject . name , 'put to sleep on frame' , this . world . _frame , 'force?' , forceY , 'at' , this . x ) ;
11651168
11661169 this . velocity . set ( 0 ) ;
11671170 this . prevVelocity . set ( 0 ) ;
@@ -1597,6 +1600,7 @@ var Body = new Class({
15971600
15981601 if ( sleepX && sleepY )
15991602 {
1603+ console . log ( 'world rebound' ) ;
16001604 this . sleep ( true ) ;
16011605 }
16021606 else if ( emitBoundsEvent && this . onWorldBounds )
@@ -1623,7 +1627,7 @@ var Body = new Class({
16231627 return ( gy === 0 || ( gy < 0 && this . isBlockedUp ( ) ) || ( gy > 0 && this . isBlockedDown ( ) ) ) ;
16241628 } ,
16251629
1626- // Check for sleeping state (called during postUpdate AFTER positioning)
1630+ // Check for sleeping state
16271631 checkSleep : function ( dx , dy )
16281632 {
16291633 if ( ! this . moves )
@@ -1646,11 +1650,12 @@ var Body = new Class({
16461650 {
16471651 this . _sleep ++ ;
16481652
1653+ // console.log(this.world._frame, 'sleeping ...', this._sleepY, this.y);
16491654 // console.log(this.gameObject.name, 'sleep y', this.y);
16501655
16511656 if ( this . _sleep >= this . sleepIterations )
16521657 {
1653- // console.log(this.world._frame, 'checkSleep sending ...');
1658+ // console.log(this.world._frame, 'checkSleep sending ...', dx, this._dx, this._sleepX, this.x, 'dy', dy, this._dy, this._sleepY, this.y );
16541659
16551660 this . sleep ( true ) ;
16561661
@@ -1676,7 +1681,7 @@ var Body = new Class({
16761681
16771682 if ( this . _sleep <= 0 )
16781683 {
1679- // console.log('body woken from postUpdate', dy);
1684+ console . log ( 'body woken from postUpdate' , dy ) ;
16801685 this . wake ( ) ;
16811686 }
16821687 }
@@ -1686,9 +1691,6 @@ var Body = new Class({
16861691 // console.log('body woken from significant change in velocity =', this.velocity.x);
16871692 this . wake ( ) ;
16881693 }
1689-
1690- this . _sleepX = this . x ;
1691- this . _sleepY = this . y ;
16921694 } ,
16931695
16941696 /**
@@ -2815,10 +2817,10 @@ var Body = new Class({
28152817 {
28162818 diff = amount - ( ( this . x + amount ) - bounds . x ) ;
28172819
2818- if ( diff !== 0 )
2819- {
2820- this . wake ( ) ;
2821- }
2820+ // if (diff !== 0)
2821+ // {
2822+ // this.wake();
2823+ // }
28222824
28232825 this . setWorldBlockedLeft ( true ) ;
28242826
@@ -2828,10 +2830,10 @@ var Body = new Class({
28282830 {
28292831 diff = amount - ( ( this . right + amount ) - bounds . right ) ;
28302832
2831- if ( diff !== 0 )
2832- {
2833- this . wake ( ) ;
2834- }
2833+ // if (diff !== 0)
2834+ // {
2835+ // this.wake();
2836+ // }
28352837
28362838 this . setWorldBlockedRight ( true ) ;
28372839
@@ -2859,11 +2861,11 @@ var Body = new Class({
28592861 }
28602862 }
28612863
2862- if ( diff !== 0 )
2863- {
2864+ // if (diff !== 0)
2865+ // {
28642866 // console.log('gmx3', diff);
2865- this . wake ( ) ;
2866- }
2867+ // this.wake();
2868+ // }
28672869
28682870 return diff ;
28692871 } ,
@@ -2887,10 +2889,10 @@ var Body = new Class({
28872889 {
28882890 diff = amount - ( ( this . y + amount ) - bounds . y ) ;
28892891
2890- if ( diff !== 0 )
2891- {
2892- this . wake ( ) ;
2893- }
2892+ // if (diff !== 0)
2893+ // {
2894+ // this.wake();
2895+ // }
28942896
28952897 this . setWorldBlockedUp ( true ) ;
28962898
@@ -2900,10 +2902,10 @@ var Body = new Class({
29002902 {
29012903 diff = amount - ( ( this . bottom + amount ) - bounds . bottom ) ;
29022904
2903- if ( diff !== 0 )
2904- {
2905- this . wake ( ) ;
2906- }
2905+ // if (diff !== 0)
2906+ // {
2907+ // this.wake();
2908+ // }
29072909
29082910 this . setWorldBlockedDown ( true ) ;
29092911
@@ -2931,10 +2933,10 @@ var Body = new Class({
29312933 }
29322934 }
29332935
2934- if ( diff !== 0 )
2935- {
2936- this . wake ( ) ;
2937- }
2936+ // if (diff !== 0)
2937+ // {
2938+ // this.wake();
2939+ // }
29382940
29392941 return diff ;
29402942 } ,
0 commit comments