Skip to content

Commit a506fcc

Browse files
committed
Added jsdocs
1 parent d457373 commit a506fcc

4 files changed

Lines changed: 224 additions & 6 deletions

File tree

src/gameobjects/components/Size.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
1+
/**
2+
* Provides methods used for getting and setting the size of a Game Object.
3+
*
4+
* @name Phaser.GameObjects.Components.Size
5+
* @mixin
6+
* @since 3.0.0
7+
*/
8+
19
var Size = {
210

11+
/**
12+
* The native (un-scaled) width of this Game Object.
13+
*
14+
* @name Phaser.GameObjects.Components.Size#width
15+
* @type {number}
16+
* @since 3.0.0
17+
*/
318
width: 0,
19+
20+
/**
21+
* The native (un-scaled) height of this Game Object.
22+
*
23+
* @name Phaser.GameObjects.Components.Size#height
24+
* @type {number}
25+
* @since 3.0.0
26+
*/
427
height: 0,
528

29+
/**
30+
* The displayed width of this Game Object.
31+
* This value takes into account the scale factor.
32+
*
33+
* @name Phaser.GameObjects.Components.Size#displayWidth
34+
* @type {number}
35+
* @since 3.0.0
36+
*/
637
displayWidth: {
738

839
get: function ()
@@ -17,6 +48,14 @@ var Size = {
1748

1849
},
1950

51+
/**
52+
* The displayed height of this Game Object.
53+
* This value takes into account the scale factor.
54+
*
55+
* @name Phaser.GameObjects.Components.Size#displayHeight
56+
* @type {number}
57+
* @since 3.0.0
58+
*/
2059
displayHeight: {
2160

2261
get: function ()
@@ -31,6 +70,16 @@ var Size = {
3170

3271
},
3372

73+
/**
74+
* Sets the size of this Game Object to be that of the given Frame.
75+
*
76+
* @method Phaser.GameObjects.Components.Size.setSizeToFrame
77+
* @since 3.0.0
78+
*
79+
* @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on.
80+
*
81+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
82+
*/
3483
setSizeToFrame: function (frame)
3584
{
3685
if (frame === undefined) { frame = this.frame; }
@@ -41,6 +90,17 @@ var Size = {
4190
return this;
4291
},
4392

93+
/**
94+
* Sets the size of this Game Object.
95+
*
96+
* @method Phaser.GameObjects.Components.Size.setSize
97+
* @since 3.0.0
98+
*
99+
* @param {number} width - The width of this Game Object.
100+
* @param {number} height - The height of this Game Object.
101+
*
102+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
103+
*/
44104
setSize: function (width, height)
45105
{
46106
this.width = width;
@@ -49,6 +109,18 @@ var Size = {
49109
return this;
50110
},
51111

112+
/**
113+
* Sets the display size of this Game Object.
114+
* Calling this will adjust the scale.
115+
*
116+
* @method Phaser.GameObjects.Components.Size.setDisplaySize
117+
* @since 3.0.0
118+
*
119+
* @param {number} width - The width of this Game Object.
120+
* @param {number} height - The height of this Game Object.
121+
*
122+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
123+
*/
52124
setDisplaySize: function (width, height)
53125
{
54126
this.displayWidth = width;

src/gameobjects/components/Texture.js

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,68 @@
1-
// Texture Component
2-
31
// bitmask flag for GameObject.renderMask
42
var _FLAG = 8; // 1000
53

4+
/**
5+
* Provides methods used for getting and setting the texture of a Game Object.
6+
*
7+
* @name Phaser.GameObjects.Components.Texture
8+
* @mixin
9+
* @since 3.0.0
10+
*/
11+
612
var Texture = {
713

14+
/**
15+
* The Texture this Game Object is using to render with.
16+
*
17+
* @name Phaser.GameObjects.Components.Texture#texture
18+
* @type {Phaser.Textures.Texture}
19+
* @since 3.0.0
20+
*/
821
texture: null,
22+
23+
/**
24+
* The Texture Frame this Game Object is using to render with.
25+
*
26+
* @name Phaser.GameObjects.Components.Texture#frame
27+
* @type {Phaser.Textures.Frame}
28+
* @since 3.0.0
29+
*/
930
frame: null,
1031

32+
/**
33+
* Sets the texture and frame this Game Object will use to render with.
34+
*
35+
* Textures are referenced by their string-based keys, as stored in the Texture Manager.
36+
*
37+
* @method Phaser.GameObjects.Components.Texture.setTexture
38+
* @since 3.0.0
39+
*
40+
* @param {string} key - The key of the texture to be used, as stored in the Texture Manager.
41+
* @param {string|integer} [frame] - The name or index of the frame within the Texture.
42+
*
43+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
44+
*/
1145
setTexture: function (key, frame)
1246
{
1347
this.texture = this.scene.sys.textures.get(key);
1448

1549
return this.setFrame(frame);
1650
},
1751

52+
/**
53+
* Sets the frame this Game Object will use to render with.
54+
*
55+
* The Frame has to belong to the current Texture being used.
56+
*
57+
* It can be either a string or an index.
58+
*
59+
* @method Phaser.GameObjects.Components.Texture.setFrame
60+
* @since 3.0.0
61+
*
62+
* @param {string|integer} frame - The name or index of the frame within the Texture.
63+
*
64+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
65+
*/
1866
setFrame: function (frame)
1967
{
2068
this.frame = this.texture.get(frame);

src/gameobjects/components/Tint.js

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
21
var GetColor = function (value)
32
{
43
return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16);
54
};
65

6+
/**
7+
* Provides methods used for setting the tint of a Game Object.
8+
* Should be applied as a mixin and not used directly.
9+
*
10+
* @name Phaser.GameObjects.Components.Tint
11+
* @mixin
12+
* @webglOnly
13+
* @since 3.0.0
14+
*/
15+
716
var Tint = {
817

918
// 0: topLeft, 1: topRight, 2: bottomLeft, 3: bottomRight
@@ -12,13 +21,37 @@ var Tint = {
1221
_tintBL: 16777215,
1322
_tintBR: 16777215,
1423

24+
/**
25+
* Clears all tint values associated with this Game Object.
26+
* Immediately sets the alpha levels back to 0xffffff (no tint)
27+
*
28+
* @method Phaser.GameObjects.Components.Tint.clearTint
29+
* @webglOnly
30+
* @since 3.0.0
31+
*
32+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
33+
*/
1534
clearTint: function ()
1635
{
1736
this.setTint(0xffffff);
1837

1938
return this;
2039
},
2140

41+
/**
42+
* Sets the tint values for this Game Object.
43+
*
44+
* @method Phaser.GameObjects.Components.Tint.setTint
45+
* @webglOnly
46+
* @since 3.0.0
47+
*
48+
* @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object.
49+
* @param {integer} [topRight] - The tint being applied to the top-right of the Game Object.
50+
* @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object.
51+
* @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object.
52+
*
53+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
54+
*/
2255
setTint: function (topLeft, topRight, bottomLeft, bottomRight)
2356
{
2457
if (topLeft === undefined) { topLeft = 0xffffff; }
@@ -38,6 +71,14 @@ var Tint = {
3871
return this;
3972
},
4073

74+
/**
75+
* The tint value being applied to the top-left of the Game Object.
76+
*
77+
* @name Phaser.GameObjects.Components.Tint#tintTopLeft
78+
* @type {integer}
79+
* @webglOnly
80+
* @since 3.0.0
81+
*/
4182
tintTopLeft: {
4283

4384
get: function ()
@@ -52,6 +93,14 @@ var Tint = {
5293

5394
},
5495

96+
/**
97+
* The tint value being applied to the top-right of the Game Object.
98+
*
99+
* @name Phaser.GameObjects.Components.Tint#tintTopRight
100+
* @type {integer}
101+
* @webglOnly
102+
* @since 3.0.0
103+
*/
55104
tintTopRight: {
56105

57106
get: function ()
@@ -66,6 +115,14 @@ var Tint = {
66115

67116
},
68117

118+
/**
119+
* The tint value being applied to the bottom-left of the Game Object.
120+
*
121+
* @name Phaser.GameObjects.Components.Tint#tintBottomLeft
122+
* @type {integer}
123+
* @webglOnly
124+
* @since 3.0.0
125+
*/
69126
tintBottomLeft: {
70127

71128
get: function ()
@@ -80,6 +137,14 @@ var Tint = {
80137

81138
},
82139

140+
/**
141+
* The tint value being applied to the bottom-right of the Game Object.
142+
*
143+
* @name Phaser.GameObjects.Components.Tint#tintBottomRight
144+
* @type {integer}
145+
* @webglOnly
146+
* @since 3.0.0
147+
*/
83148
tintBottomRight: {
84149

85150
get: function ()
@@ -94,6 +159,14 @@ var Tint = {
94159

95160
},
96161

162+
/**
163+
* The tint value being applied to the whole of the Game Object.
164+
*
165+
* @name Phaser.GameObjects.Components.Tint#tint
166+
* @type {integer}
167+
* @webglOnly
168+
* @since 3.0.0
169+
*/
97170
tint: {
98171

99172
set: function (value)

src/gameobjects/components/Visible.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
2-
// Visible Component
3-
41
// bitmask flag for GameObject.renderMask
52
var _FLAG = 1; // 0001
63

4+
/**
5+
* Provides methods used for setting the visibility of a Game Object.
6+
* Should be applied as a mixin and not used directly.
7+
*
8+
* @name Phaser.GameObjects.Components.Visible
9+
* @mixin
10+
* @since 3.0.0
11+
*/
12+
713
var Visible = {
814

915
_visible: true,
1016

17+
/**
18+
* The visible state of the Game Object.
19+
*
20+
* An invisible Game Object will skip rendering, but still process update logic.
21+
*
22+
* @name Phaser.GameObjects.Components.Visible#visible
23+
* @type {boolean}
24+
* @since 3.0.0
25+
*/
1126
visible: {
1227

1328
get: function ()
@@ -31,6 +46,16 @@ var Visible = {
3146

3247
},
3348

49+
/**
50+
* Sets the visibility of this Game Object.
51+
*
52+
* @method Phaser.GameObjects.Components.Visible.setVisible
53+
* @since 3.0.0
54+
*
55+
* @param {boolean} value - The visible state of the Game Object.
56+
*
57+
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
58+
*/
3459
setVisible: function (value)
3560
{
3661
this.visible = value;

0 commit comments

Comments
 (0)