Skip to content

Commit b0bb397

Browse files
committed
Added jsdocs
1 parent 26a496a commit b0bb397

5 files changed

Lines changed: 212 additions & 27 deletions

File tree

src/gameobjects/components/Alpha.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ var Alpha = {
7272
},
7373

7474
/**
75-
* [description]
75+
* The alpha value of the Game Object.
76+
*
77+
* This is a global value, impacting the entire Game Object, not just a region of it.
7678
*
7779
* @name Phaser.GameObjects.Components.Alpha#alpha
7880
* @type {float}
@@ -108,7 +110,8 @@ var Alpha = {
108110
},
109111

110112
/**
111-
* [description]
113+
* The alpha value starting from the top-left of the Game Object.
114+
* This value is interpolated from the corner to the center of the Game Object.
112115
*
113116
* @name Phaser.GameObjects.Components.Alpha#alphaTopLeft
114117
* @type {float}
@@ -137,7 +140,8 @@ var Alpha = {
137140
},
138141

139142
/**
140-
* [description]
143+
* The alpha value starting from the top-right of the Game Object.
144+
* This value is interpolated from the corner to the center of the Game Object.
141145
*
142146
* @name Phaser.GameObjects.Components.Alpha#alphaTopRight
143147
* @type {float}
@@ -166,7 +170,8 @@ var Alpha = {
166170
},
167171

168172
/**
169-
* [description]
173+
* The alpha value starting from the bottom-left of the Game Object.
174+
* This value is interpolated from the corner to the center of the Game Object.
170175
*
171176
* @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft
172177
* @type {float}
@@ -195,7 +200,8 @@ var Alpha = {
195200
},
196201

197202
/**
198-
* [description]
203+
* The alpha value starting from the bottom-right of the Game Object.
204+
* This value is interpolated from the corner to the center of the Game Object.
199205
*
200206
* @name Phaser.GameObjects.Components.Alpha#alphaBottomRight
201207
* @type {float}

src/gameobjects/components/BlendMode.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,24 @@ var BlendMode = {
1313
_blendMode: BlendModes.NORMAL,
1414

1515
/**
16-
* [description]
16+
* Sets the Blend Mode being used by this Game Object.
17+
*
18+
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
19+
*
20+
* Under WebGL only the following Blend Modes are available:
21+
*
22+
* * ADD
23+
* * MULTIPLY
24+
* * SCREEN
25+
*
26+
* Canvas has more available depending on browser support.
27+
*
28+
* You can also create your own custom Blend Modes in WebGL.
29+
*
30+
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
31+
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
32+
* reasons try to be careful about the construction of your Scene and the frequency of which blend modes
33+
* are used.
1734
*
1835
* @name Phaser.GameObjects.Components.BlendMode#blendMode
1936
* @type {integer|string}
@@ -58,6 +75,11 @@ var BlendMode = {
5875
*
5976
* You can also create your own custom Blend Modes in WebGL.
6077
*
78+
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
79+
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
80+
* reasons try to be careful about the construction of your Scene and the frequency of which blend modes
81+
* are used.
82+
*
6183
* @method Phaser.GameObjects.Components.BlendMode#setBlendMode
6284
* @since 3.0.0
6385
*

src/gameobjects/zone/Zone.js

Lines changed: 144 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
var BlendModes = require('../../renderer/BlendModes');
32
var Circle = require('../../geom/circle/Circle');
43
var CircleContains = require('../../geom/circle/Contains');
@@ -8,14 +7,38 @@ var GameObject = require('../GameObject');
87
var Rectangle = require('../../geom/rectangle/Rectangle');
98
var RectangleContains = require('../../geom/rectangle/Contains');
109

11-
// A Zone is a non-rendering rectangular Game Object that has a position and size.
12-
// It has no texture and never renders, but does live on the display list and
13-
// can be moved, scaled and rotated like any other Game Object.
14-
15-
// The default origin is 0.5, the center of the Zone, the same as with Game Objects.
16-
// It's useful for linking to drop zones and input hit areas and has a couple of helper methods specifically for this.
17-
// Also useful for object overlap checks, or as a base for your own non-displaying objects.
18-
10+
/**
11+
* A Zone Game Object.
12+
*
13+
* A Zone is a non-rendering rectangular Game Object that has a position and size.
14+
* It has no texture and never displays, but does live on the display list and
15+
* can be moved, scaled and rotated like any other Game Object.
16+
*
17+
* Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods
18+
* specifically for this. It is also useful for object overlap checks, or as a base for your own
19+
* non-displaying Game Objects.
20+
21+
* The default origin is 0.5, the center of the Zone, the same as with Game Objects.
22+
*
23+
* @class Zone
24+
* @extends Phaser.GameObjects.GameObject
25+
* @memberOf Phaser.GameObjects
26+
* @constructor
27+
* @since 3.0.0
28+
*
29+
* @extends Phaser.GameObjects.Components.GetBounds
30+
* @extends Phaser.GameObjects.Components.Origin
31+
* @extends Phaser.GameObjects.Components.ScaleMode
32+
* @extends Phaser.GameObjects.Components.Transform
33+
* @extends Phaser.GameObjects.Components.ScrollFactor
34+
* @extends Phaser.GameObjects.Components.Visible
35+
*
36+
* @param {Phaser.Scene} scene - [description]
37+
* @param {number} x - The horizontal position of this Game Object in the world.
38+
* @param {number} y - The vertical position of this Game Object in the world.
39+
* @param {number} [width=1] - The width of the Game Object.
40+
* @param {number} [height=1] - The height of the Game Object.
41+
*/
1942
var Zone = new Class({
2043

2144
Extends: GameObject,
@@ -40,12 +63,44 @@ var Zone = new Class({
4063

4164
this.setPosition(x, y);
4265

66+
/**
67+
* The native (un-scaled) width of this Game Object.
68+
*
69+
* @name Phaser.GameObjects.Zone#width
70+
* @type {number}
71+
* @since 3.0.0
72+
*/
4373
this.width = width;
74+
75+
/**
76+
* The native (un-scaled) height of this Game Object.
77+
*
78+
* @name Phaser.GameObjects.Zone#height
79+
* @type {number}
80+
* @since 3.0.0
81+
*/
4482
this.height = height;
4583

84+
/**
85+
* The Blend Mode of the Game Object.
86+
* Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into
87+
* display lists without causing a batch flush.
88+
*
89+
* @name Phaser.GameObjects.Zone#blendMode
90+
* @type {integer}
91+
* @since 3.0.0
92+
*/
4693
this.blendMode = BlendModes.NORMAL;
4794
},
4895

96+
/**
97+
* The displayed width of this Game Object.
98+
* This value takes into account the scale factor.
99+
*
100+
* @name Phaser.GameObjects.Zone#displayWidth
101+
* @type {number}
102+
* @since 3.0.0
103+
*/
49104
displayWidth: {
50105

51106
get: function ()
@@ -60,6 +115,14 @@ var Zone = new Class({
60115

61116
},
62117

118+
/**
119+
* The displayed height of this Game Object.
120+
* This value takes into account the scale factor.
121+
*
122+
* @name Phaser.GameObjects.Zone#displayHeight
123+
* @type {number}
124+
* @since 3.0.0
125+
*/
63126
displayHeight: {
64127

65128
get: function ()
@@ -74,6 +137,18 @@ var Zone = new Class({
74137

75138
},
76139

140+
/**
141+
* Sets the size of this Game Object.
142+
*
143+
* @method Phaser.GameObjects.Zone#setSize
144+
* @since 3.0.0
145+
*
146+
* @param {number} width - The width of this Game Object.
147+
* @param {number} height - The height of this Game Object.
148+
* @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well.
149+
*
150+
* @return {Phaser.GameObjects.Zone} This Game Object.
151+
*/
77152
setSize: function (width, height, resizeInput)
78153
{
79154
if (resizeInput === undefined) { resizeInput = true; }
@@ -90,6 +165,18 @@ var Zone = new Class({
90165
return this;
91166
},
92167

168+
/**
169+
* Sets the display size of this Game Object.
170+
* Calling this will adjust the scale.
171+
*
172+
* @method Phaser.GameObjects.Zone#setDisplaySize
173+
* @since 3.0.0
174+
*
175+
* @param {number} width - The width of this Game Object.
176+
* @param {number} height - The height of this Game Object.
177+
*
178+
* @return {Phaser.GameObjects.Zone} This Game Object.
179+
*/
93180
setDisplaySize: function (width, height)
94181
{
95182
this.displayWidth = width;
@@ -98,13 +185,34 @@ var Zone = new Class({
98185
return this;
99186
},
100187

101-
// Centered on the Zones x/y
188+
/**
189+
* Sets this Zone to be a Circular Drop Zone.
190+
* The circle is centered on this Zones `x` and `y` coordinates.
191+
*
192+
* @method Phaser.GameObjects.Zone#setCircleDropZone
193+
* @since 3.0.0
194+
*
195+
* @param {number} radius - The radius of the Circle that will form the Drop Zone.
196+
*
197+
* @return {Phaser.GameObjects.Zone} This Game Object.
198+
*/
102199
setCircleDropZone: function (radius)
103200
{
104201
return this.setDropZone(new Circle(0, 0, radius), CircleContains);
105202
},
106203

107-
// Centered on the Zones x/y position
204+
/**
205+
* Sets this Zone to be a Rectangle Drop Zone.
206+
* The rectangle is centered on this Zones `x` and `y` coordinates.
207+
*
208+
* @method Phaser.GameObjects.Zone#setRectangleDropZone
209+
* @since 3.0.0
210+
*
211+
* @param {number} width - The width of the rectangle drop zone.
212+
* @param {number} height - The height of the rectangle drop zone.
213+
*
214+
* @return {Phaser.GameObjects.Zone} This Game Object.
215+
*/
108216
setRectangleDropZone: function (width, height)
109217
{
110218
var x = -(width / 2);
@@ -113,7 +221,17 @@ var Zone = new Class({
113221
return this.setDropZone(new Rectangle(x, y, width, height), RectangleContains);
114222
},
115223

116-
// Define your own shape as the drop zone
224+
/**
225+
* Allows you to define your own Geometry shape to be used as a Drop Zone.
226+
*
227+
* @method Phaser.GameObjects.Zone#setDropZone
228+
* @since 3.0.0
229+
*
230+
* @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape.
231+
* @param {function} callback - A function that will return `true` if the given x/y coords it is sent are within the shape.
232+
*
233+
* @return {Phaser.GameObjects.Zone} This Game Object.
234+
*/
117235
setDropZone: function (shape, callback)
118236
{
119237
if (shape === undefined)
@@ -133,14 +251,26 @@ var Zone = new Class({
133251
return this;
134252
},
135253

254+
/**
255+
* A Zone does not render.
256+
*
257+
* @method Phaser.GameObjects.Zone#renderCanvas
258+
* @private
259+
* @since 3.0.0
260+
*/
136261
renderCanvas: function ()
137262
{
138-
return;
139263
},
140264

265+
/**
266+
* A Zone does not render.
267+
*
268+
* @method Phaser.GameObjects.Zone#renderWebGL
269+
* @private
270+
* @since 3.0.0
271+
*/
141272
renderWebGL: function ()
142273
{
143-
return;
144274
}
145275

146276
});

src/gameobjects/zone/ZoneCreator.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@ var GameObjectCreator = require('../GameObjectCreator');
22
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
33
var Zone = require('./Zone');
44

5-
// When registering a factory function 'this' refers to the GameObjectCreator context.
6-
5+
/**
6+
* Creates a new Zone Game Object and returns it.
7+
*
8+
* Note: This method will only be available if the Zone Game Object has been built into Phaser.
9+
*
10+
* @method Phaser.GameObjects.GameObjectCreator#zone
11+
* @since 3.0.0
12+
*
13+
* @param {object} config - [description]
14+
*
15+
* @return {Phaser.GameObjects.Zone} The Game Object that was created.
16+
*/
717
GameObjectCreator.register('zone', function (config)
818
{
919
var x = GetAdvancedValue(config, 'x', 0);
@@ -13,3 +23,5 @@ GameObjectCreator.register('zone', function (config)
1323

1424
return new Zone(this.scene, x, y, width, height);
1525
});
26+
27+
// When registering a factory function 'this' refers to the GameObjectCreator context.

src/gameobjects/zone/ZoneFactory.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
var Zone = require('./Zone');
22
var GameObjectFactory = require('../GameObjectFactory');
33

4+
/**
5+
* Creates a new Zone Game Object and adds it to the Scene.
6+
*
7+
* Note: This method will only be available if the Zone Game Object has been built into Phaser.
8+
*
9+
* @method Phaser.GameObjects.GameObjectFactory#zone
10+
* @since 3.0.0
11+
*
12+
* @param {number} x - The horizontal position of this Game Object in the world.
13+
* @param {number} y - The vertical position of this Game Object in the world.
14+
* @param {number} width - The width of the Game Object.
15+
* @param {number} height - The height of the Game Object.
16+
*
17+
* @return {Phaser.GameObjects.Zone} The Game Object that was created.
18+
*/
19+
GameObjectFactory.register('zone', function (x, y, width, height)
20+
{
21+
return this.displayList.add(new Zone(this.scene, x, y, width, height));
22+
});
23+
424
// When registering a factory function 'this' refers to the GameObjectFactory context.
525
//
626
// There are several properties available to use:
727
//
828
// this.scene - a reference to the Scene that owns the GameObjectFactory
929
// this.displayList - a reference to the Display List the Scene owns
1030
// this.updateList - a reference to the Update List the Scene owns
11-
12-
GameObjectFactory.register('zone', function (x, y, width, height)
13-
{
14-
return this.displayList.add(new Zone(this.scene, x, y, width, height));
15-
});

0 commit comments

Comments
 (0)