Skip to content

Commit 11c0520

Browse files
committed
Clear wasTouching when resetting body
1 parent 57ee895 commit 11c0520

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

src/physics/arcade/Body.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -934,19 +934,37 @@ var Body = new Class({
934934
*
935935
* @method Phaser.Physics.Arcade.Body#resetFlags
936936
* @since 3.18.0
937+
*
938+
* @param {boolean} [clear=false] - Set the `wasTouching` values to their defaults.
937939
*/
938-
resetFlags: function ()
940+
resetFlags: function (clear)
939941
{
942+
if (clear === undefined)
943+
{
944+
clear = false;
945+
}
946+
940947
// Store and reset collision flags
941948
var wasTouching = this.wasTouching;
942949
var touching = this.touching;
943950
var blocked = this.blocked;
944951

945-
wasTouching.none = touching.none;
946-
wasTouching.up = touching.up;
947-
wasTouching.down = touching.down;
948-
wasTouching.left = touching.left;
949-
wasTouching.right = touching.right;
952+
if (clear)
953+
{
954+
wasTouching.none = true;
955+
wasTouching.up = false;
956+
wasTouching.down = false;
957+
wasTouching.left = false;
958+
wasTouching.right = false;
959+
}
960+
else
961+
{
962+
wasTouching.none = touching.none;
963+
wasTouching.up = touching.up;
964+
wasTouching.down = touching.down;
965+
wasTouching.left = touching.left;
966+
wasTouching.right = touching.right;
967+
}
950968

951969
touching.none = true;
952970
touching.up = false;
@@ -1353,7 +1371,7 @@ var Body = new Class({
13531371

13541372
this.updateBounds();
13551373
this.updateCenter();
1356-
this.resetFlags();
1374+
this.resetFlags(true);
13571375
},
13581376

13591377
/**

0 commit comments

Comments
 (0)