Merge pull request #5315 from samme/feature/onWorldBounds

Add onWorldBounds argument in Arcade.Body#setCollideWorldBounds()
This commit is contained in:
Richard Davey 2020-09-21 09:38:05 +01:00 committed by GitHub
commit 3672559fc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1687,18 +1687,19 @@ var Body = new Class({
/**
* Sets whether this Body collides with the world boundary.
*
* Optionally also sets the World Bounce values. If the `Body.worldBounce` is null, it's set to a new Phaser.Math.Vector2 first.
* Optionally also sets the World Bounce and `onWorldBounds` values.
*
* @method Phaser.Physics.Arcade.Body#setCollideWorldBounds
* @since 3.0.0
*
* @param {boolean} [value=true] - `true` if this body should collide with the world bounds, otherwise `false`.
* @param {number} [bounceX] - If given this will be replace the `worldBounce.x` value.
* @param {number} [bounceY] - If given this will be replace the `worldBounce.y` value.
* @param {boolean} [value=true] - `true` if the Body should collide with the world bounds, otherwise `false`.
* @param {number} [bounceX] - If given this replaces the Body's `worldBounce.x` value.
* @param {number} [bounceY] - If given this replaces the Body's `worldBounce.y` value.
* @param {boolean} [onWorldBounds] - If given this replaces the Body's `onWorldBounds` value.
*
* @return {Phaser.Physics.Arcade.Body} This Body object.
*/
setCollideWorldBounds: function (value, bounceX, bounceY)
setCollideWorldBounds: function (value, bounceX, bounceY, onWorldBounds)
{
if (value === undefined) { value = true; }
@ -1725,6 +1726,11 @@ var Body = new Class({
}
}
if (onWorldBounds !== undefined)
{
this.onWorldBounds = onWorldBounds;
}
return this;
},