@@ -686,15 +686,6 @@ var Body = new Class({
686686 */
687687 this . blocked = { none : true , up : false , down : false , left : false , right : false , by : null } ;
688688
689- /**
690- * Whether this Body was blocked from moving in a given direction during the last step.
691- *
692- * @name Phaser.Physics.Arcade.Body#wasBlocked
693- * @type {Phaser.Physics.Arcade.Types.ArcadeBodyCollision }
694- * @since 3.17.0
695- */
696- this . wasBlocked = { none : true , up : false , down : false , left : false , right : false } ;
697-
698689 /**
699690 * Whether this Body is colliding with a tile or the world boundary.
700691 *
@@ -894,8 +885,6 @@ var Body = new Class({
894885 */
895886 preUpdate : function ( )
896887 {
897- console . log ( 'preUpdate' , this . wasBlocked . down ) ;
898-
899888 var touching = this . touching ;
900889 var blocked = this . blocked ;
901890 var worldBlocked = this . worldBlocked ;
@@ -935,8 +924,6 @@ var Body = new Class({
935924
936925 if ( this . collideWorldBounds && this . checkWorldBounds ( ) )
937926 {
938- console . log ( 'preUpdate cwb' , worldBlocked . down , 'was' , this . wasBlocked . down ) ;
939-
940927 blocked . up = worldBlocked . up ;
941928 blocked . down = worldBlocked . down ;
942929 blocked . left = worldBlocked . left ;
@@ -972,8 +959,6 @@ var Body = new Class({
972959 */
973960 update : function ( delta )
974961 {
975- console . log ( 'update' , this . wasBlocked . down ) ;
976-
977962 var velocity = this . velocity ;
978963 var position = this . position ;
979964
@@ -985,8 +970,6 @@ var Body = new Class({
985970 position . y += this . getMoveY ( velocity . y * delta ) ;
986971 }
987972
988- console . log ( 'update2' , this . worldBlocked . down , 'was' , this . wasBlocked . down ) ;
989-
990973 // Calculate the delta
991974 this . _dx = position . x - this . prev . x ;
992975 this . _dy = position . y - this . prev . y ;
@@ -996,61 +979,28 @@ var Body = new Class({
996979 // World Bounds check
997980 if ( this . collideWorldBounds )
998981 {
999- console . log ( 'update3' , this . wasBlocked . down , 'w' , this . worldBlocked . down , 'n' , this . worldBlocked . none ) ;
1000-
1001- var wasBlocked = this . wasBlocked ;
1002-
1003982 if ( ! worldBlocked . none )
1004983 {
1005984 var bx = ( this . worldBounce ) ? - this . worldBounce . x : - this . bounce . x ;
1006985 var by = ( this . worldBounce ) ? - this . worldBounce . y : - this . bounce . y ;
1007986
1008987 // Reverse the velocity for the bounce
1009988
1010- // if ((worldBlocked.left && velocity.x < 0) || (worldBlocked.right && velocity.x > 0))
1011- // {
1012- // velocity.x *= bx;
1013- // }
1014-
1015- console . log ( worldBlocked . down , wasBlocked . down ) ;
1016-
1017- if ( worldBlocked . down && velocity . y > 0 )
989+ if ( ( worldBlocked . left && velocity . x < 0 ) || ( worldBlocked . right && velocity . x > 0 ) )
1018990 {
1019- velocity . y *= by ;
1020-
1021- // vy should now be negative
1022-
1023- console . log ( 'down' , velocity . y , this . _dy , wasBlocked . down ) ;
1024-
1025- // if (this._dy < -this.minBounceVelocity.y)
1026- // {
1027- // velocity.y = 0;
1028- // }
991+ velocity . x *= bx ;
1029992 }
1030- else if ( worldBlocked . up && velocity . y < 0 )
993+
994+ if ( ( worldBlocked . down && velocity . y > 0 ) || ( worldBlocked . up && velocity . y < 0 ) )
1031995 {
1032- // vy should now be positive
1033996 velocity . y *= by ;
1034-
1035- console . log ( 'up' , velocity . y , this . _dy , wasBlocked . up ) ;
1036-
1037- // if (this._dy < this.minBounceVelocity.y)
1038- // {
1039- // velocity.y = 0;
1040- // }
1041997 }
1042998 }
1043999
10441000 if ( this . onWorldBounds )
10451001 {
10461002 this . world . emit ( Events . WORLD_BOUNDS , this , worldBlocked . up , worldBlocked . down , worldBlocked . left , worldBlocked . right ) ;
10471003 }
1048-
1049- wasBlocked . none = worldBlocked . none ;
1050- wasBlocked . up = worldBlocked . up ;
1051- wasBlocked . down = worldBlocked . down ;
1052- wasBlocked . left = worldBlocked . left ;
1053- wasBlocked . right = worldBlocked . right ;
10541004 }
10551005
10561006 this . updateCenter ( ) ;
@@ -1138,24 +1088,14 @@ var Body = new Class({
11381088
11391089 // Store collision flags
11401090 var wasTouching = this . wasTouching ;
1141- var wasBlocked = this . wasBlocked ;
11421091 var touching = this . touching ;
1143- var worldBlocked = this . worldBlocked ;
11441092
11451093 wasTouching . none = touching . none ;
11461094 wasTouching . up = touching . up ;
11471095 wasTouching . down = touching . down ;
11481096 wasTouching . left = touching . left ;
11491097 wasTouching . right = touching . right ;
11501098
1151- console . log ( 'postUpdate' , worldBlocked . down , 'was' , wasBlocked . down ) ;
1152-
1153- // wasBlocked.none = worldBlocked.none;
1154- // wasBlocked.up = worldBlocked.up;
1155- // wasBlocked.down = worldBlocked.down;
1156- // wasBlocked.left = worldBlocked.left;
1157- // wasBlocked.right = worldBlocked.right;
1158-
11591099 this . prev . x = this . position . x ;
11601100 this . prev . y = this . position . y ;
11611101 } ,
@@ -1177,26 +1117,26 @@ var Body = new Class({
11771117 var check = this . world . checkCollision ;
11781118 var set = false ;
11791119
1180- if ( pos . x <= bounds . x && check . left )
1120+ if ( check . left && pos . x < bounds . x )
11811121 {
11821122 set = true ;
11831123 pos . x = bounds . x ;
11841124 worldBlocked . left = true ;
11851125 }
1186- else if ( this . right >= bounds . right && check . right )
1126+ else if ( check . right && this . right > bounds . right )
11871127 {
11881128 set = true ;
11891129 pos . x = bounds . right - this . width ;
11901130 worldBlocked . right = true ;
11911131 }
11921132
1193- if ( check . up && pos . y <= bounds . y )
1133+ if ( check . up && pos . y < bounds . y )
11941134 {
11951135 set = true ;
11961136 pos . y = bounds . y ;
11971137 worldBlocked . up = true ;
11981138 }
1199- else if ( check . down && this . bottom >= bounds . bottom )
1139+ else if ( check . down && this . bottom > bounds . bottom )
12001140 {
12011141 set = true ;
12021142 pos . y = bounds . bottom - this . height ;
0 commit comments