-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
Friction.js
82 lines (73 loc) · 2.27 KB
/
Friction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Methods for setting the friction of an Arcade Physics Body.
*
* In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body.
*
* @namespace Phaser.Physics.Arcade.Components.Friction
* @since 3.0.0
*
* @see Phaser.Physics.Arcade.Body#friction
*/
var Friction = {
/**
* Sets the friction of this game object's physics body.
* In Arcade Physics, friction is a special case of motion transfer from an "immovable" body to a riding body.
*
* @method Phaser.Physics.Arcade.Components.Friction#setFriction
* @since 3.0.0
*
* @param {number} x - The amount of horizontal friction to apply, [0, 1].
* @param {number} [y=x] - The amount of vertical friction to apply, [0, 1].
*
* @return {this} This Game Object.
*
* @see Phaser.Physics.Arcade.Body#friction
*/
setFriction: function (x, y)
{
this.body.friction.set(x, y);
return this;
},
/**
* Sets the horizontal friction of this game object's physics body.
* This can move a riding body horizontally when it collides with this one on the vertical axis.
*
* @method Phaser.Physics.Arcade.Components.Friction#setFrictionX
* @since 3.0.0
*
* @param {number} x - The amount of friction to apply, [0, 1].
*
* @return {this} This Game Object.
*
* @see Phaser.Physics.Arcade.Body#friction
*/
setFrictionX: function (x)
{
this.body.friction.x = x;
return this;
},
/**
* Sets the vertical friction of this game object's physics body.
* This can move a riding body vertically when it collides with this one on the horizontal axis.
*
* @method Phaser.Physics.Arcade.Components.Friction#setFrictionY
* @since 3.0.0
*
* @param {number} y - The amount of friction to apply, [0, 1].
*
* @return {this} This Game Object.
*
* @see Phaser.Physics.Arcade.Body#friction
*/
setFrictionY: function (y)
{
this.body.friction.y = y;
return this;
}
};
module.exports = Friction;