forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlip.js
More file actions
158 lines (140 loc) · 4.76 KB
/
Copy pathFlip.js
File metadata and controls
158 lines (140 loc) · 4.76 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Provides methods used for visually flipping a Game Object.
* Should be applied as a mixin and not used directly.
*
* @namespace Phaser.GameObjects.Components.Flip
* @since 3.0.0
*/
var Flip = {
/**
* The horizontally flipped state of the Game Object.
*
* A Game Object that is flipped horizontally will render inversed on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*
* @name Phaser.GameObjects.Components.Flip#flipX
* @type {boolean}
* @default false
* @since 3.0.0
*/
flipX: false,
/**
* The vertically flipped state of the Game Object.
*
* A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down)
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*
* @name Phaser.GameObjects.Components.Flip#flipY
* @type {boolean}
* @default false
* @since 3.0.0
*/
flipY: false,
/**
* Toggles the horizontal flipped state of this Game Object.
*
* A Game Object that is flipped horizontally will render inversed on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*
* @method Phaser.GameObjects.Components.Flip#toggleFlipX
* @since 3.0.0
*
* @return {this} This Game Object instance.
*/
toggleFlipX: function ()
{
this.flipX = !this.flipX;
return this;
},
/**
* Toggles the vertical flipped state of this Game Object.
*
* @method Phaser.GameObjects.Components.Flip#toggleFlipY
* @since 3.0.0
*
* @return {this} This Game Object instance.
*/
toggleFlipY: function ()
{
this.flipY = !this.flipY;
return this;
},
/**
* Sets the horizontal flipped state of this Game Object.
*
* A Game Object that is flipped horizontally will render inversed on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*
* @method Phaser.GameObjects.Components.Flip#setFlipX
* @since 3.0.0
*
* @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped.
*
* @return {this} This Game Object instance.
*/
setFlipX: function (value)
{
this.flipX = value;
return this;
},
/**
* Sets the vertical flipped state of this Game Object.
*
* @method Phaser.GameObjects.Components.Flip#setFlipY
* @since 3.0.0
*
* @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped.
*
* @return {this} This Game Object instance.
*/
setFlipY: function (value)
{
this.flipY = value;
return this;
},
/**
* Sets the horizontal and vertical flipped state of this Game Object.
*
* A Game Object that is flipped will render inversed on the flipped axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
* If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
*
* @method Phaser.GameObjects.Components.Flip#setFlip
* @since 3.0.0
*
* @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped.
* @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped.
*
* @return {this} This Game Object instance.
*/
setFlip: function (x, y)
{
this.flipX = x;
this.flipY = y;
return this;
},
/**
* Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state.
*
* @method Phaser.GameObjects.Components.Flip#resetFlip
* @since 3.0.0
*
* @return {this} This Game Object instance.
*/
resetFlip: function ()
{
this.flipX = false;
this.flipY = false;
return this;
}
};
module.exports = Flip;