phaser/src/physics/arcade/components/Friction.js

73 lines
2.3 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
2018-09-28 11:19:21 +00:00
* Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. The higher than friction, the faster the body will slow down once force stops being applied to it.
*
* @name Phaser.Physics.Arcade.Components.Friction
* @since 3.0.0
*/
var Friction = {
/**
2018-09-28 11:19:21 +00:00
* Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving.
* The higher than friction, the faster the body will slow down once force stops being applied to it.
*
* @method Phaser.Physics.Arcade.Components.Friction#setFriction
* @since 3.0.0
*
2018-09-28 11:19:21 +00:00
* @param {number} x - The amount of horizontal friction to apply.
* @param {number} [y=x] - The amount of vertical friction to apply.
*
* @return {this} This Game Object.
*/
setFriction: function (x, y)
{
this.body.friction.set(x, y);
return this;
},
/**
2018-09-28 11:19:21 +00:00
* Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis.
* The higher than friction, the faster the body will slow down once force stops being applied to it.
*
* @method Phaser.Physics.Arcade.Components.Friction#setFrictionX
* @since 3.0.0
*
2018-09-28 11:19:21 +00:00
* @param {number} x - The amount of friction to apply.
*
* @return {this} This Game Object.
*/
setFrictionX: function (x)
{
this.body.friction.x = x;
return this;
},
/**
2018-09-28 11:19:21 +00:00
* Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis.
* The higher than friction, the faster the body will slow down once force stops being applied to it.
*
* @method Phaser.Physics.Arcade.Components.Friction#setFrictionY
* @since 3.0.0
*
2018-09-28 11:19:21 +00:00
* @param {number} x - The amount of friction to apply.
*
* @return {this} This Game Object.
*/
setFrictionY: function (y)
{
this.body.friction.y = y;
return this;
}
};
module.exports = Friction;