Merge pull request #5322 from samme/feature/setMaxVelocity

Set maxVelocity in PhysicsGroupConfig
This commit is contained in:
Richard Davey 2020-09-23 13:06:52 +01:00 committed by GitHub
commit 1f9243fe81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 0 deletions

View file

@ -1819,6 +1819,40 @@ var Body = new Class({
return this;
},
/**
* Sets the Body's maximum horizontal velocity.
*
* @method Phaser.Physics.Arcade.Body#setMaxVelocityX
* @since 3.50.0
*
* @param {number} value - The maximum horizontal velocity, in pixels per second.
*
* @return {Phaser.Physics.Arcade.Body} This Body object.
*/
setMaxVelocityX: function (value)
{
this.maxVelocity.x = value;
return this;
},
/**
* Sets the Body's maximum vertical velocity.
*
* @method Phaser.Physics.Arcade.Body#setMaxVelocityY
* @since 3.50.0
*
* @param {number} value - The maximum vertical velocity, in pixels per second.
*
* @return {Phaser.Physics.Arcade.Body} This Body object.
*/
setMaxVelocityY: function (value)
{
this.maxVelocity.y = value;
return this;
},
/**
* Sets the maximum speed the Body can move.
*

View file

@ -145,6 +145,8 @@ var PhysicsGroup = new Class({
setGravityY: GetFastValue(config, 'gravityY', 0),
setFrictionX: GetFastValue(config, 'frictionX', 0),
setFrictionY: GetFastValue(config, 'frictionY', 0),
setMaxVelocityX: GetFastValue(config, 'maxVelocityX', 10000),
setMaxVelocityY: GetFastValue(config, 'maxVelocityY', 10000),
setVelocityX: GetFastValue(config, 'velocityX', 0),
setVelocityY: GetFastValue(config, 'velocityY', 0),
setAngularVelocity: GetFastValue(config, 'angularVelocity', 0),

View file

@ -19,6 +19,8 @@
* @property {number} [gravityY=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.y}.
* @property {number} [frictionX=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.x}.
* @property {number} [frictionY=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.y}.
* @property {number} [maxVelocityX=10000] - Sets {@link Phaser.Physics.Arcade.Body#maxVelocity maxVelocity.x}.
* @property {number} [maxVelocityY=10000] - Sets {@link Phaser.Physics.Arcade.Body#maxVelocity maxVelocity.y}.
* @property {number} [velocityX=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.x}.
* @property {number} [velocityY=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.y}.
* @property {number} [angularVelocity=0] - Sets {@link Phaser.Physics.Arcade.Body#angularVelocity}.