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-02-09 01:40:41 +00:00
|
|
|
/**
|
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.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Arcade.Components.Friction
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-11-09 04:02:31 +00:00
|
|
|
var Friction = {
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
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.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
|
|
|
* @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.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
2018-05-22 08:09:28 +00:00
|
|
|
* @return {this} This Game Object.
|
2018-02-09 01:40:41 +00:00
|
|
|
*/
|
2017-11-09 04:02:31 +00:00
|
|
|
setFriction: function (x, y)
|
|
|
|
{
|
|
|
|
this.body.friction.set(x, y);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
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.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
|
|
|
* @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.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
2018-05-22 08:09:28 +00:00
|
|
|
* @return {this} This Game Object.
|
2018-02-09 01:40:41 +00:00
|
|
|
*/
|
2017-11-09 04:02:31 +00:00
|
|
|
setFrictionX: function (x)
|
|
|
|
{
|
|
|
|
this.body.friction.x = x;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
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.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
|
|
|
* @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.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
2018-05-22 08:09:28 +00:00
|
|
|
* @return {this} This Game Object.
|
2018-02-09 01:40:41 +00:00
|
|
|
*/
|
2017-11-09 04:02:31 +00:00
|
|
|
setFrictionY: function (y)
|
|
|
|
{
|
|
|
|
this.body.friction.y = y;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Friction;
|