Skip to content

Commit 124b0ff

Browse files
committed
Documented Light, LightsManager and LightsPlugin.
Documented class description for TransformMatrix. Added a missing description from Container's EachContainerCallback.
1 parent 19eb363 commit 124b0ff

5 files changed

Lines changed: 82 additions & 40 deletions

File tree

src/gameobjects/components/TransformMatrix.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ var Class = require('../../utils/Class');
88

99
/**
1010
* @classdesc
11-
* [description]
11+
* A Matrix used for display transformations for rendering.
12+
*
13+
* It is represented like so:
14+
*
15+
* ```
16+
* | a | c | tx |
17+
* | b | d | ty |
18+
* | 0 | 0 | 1 |
19+
* ```
1220
*
1321
* @class TransformMatrix
1422
* @memberOf Phaser.GameObjects.Components

src/gameobjects/container/Container.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ var Container = new Class({
10011001
* @callback EachContainerCallback
10021002
* @generic I - [item]
10031003
*
1004-
* @param {*} item - [description]
1004+
* @param {*} item - The child Game Object of the Container.
10051005
* @param {...*} [args] - Additional arguments that will be passed to the callback, after the child.
10061006
*/
10071007

src/gameobjects/lights/Light.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ var Utils = require('../../renderer/webgl/Utils');
1111
* @classdesc
1212
* A 2D point light.
1313
*
14-
* Add these to a scene using the ForwardDiffuseLightPipeline for lighting effects, or just to represent a point light.
14+
* These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
15+
*
16+
* Any Game Objects using the Light2D pipeline will then be affected by these Lights.
17+
*
18+
* They can also simply be used to represent a point light for your own purposes.
1519
*
1620
* @class Light
1721
* @memberOf Phaser.GameObjects
@@ -180,7 +184,7 @@ var Light = new Class({
180184
* @method Phaser.GameObjects.Light#setColor
181185
* @since 3.0.0
182186
*
183-
* @param {number} rgb - [description]
187+
* @param {number} rgb - The integer RGB color of the light.
184188
*
185189
* @return {Phaser.GameObjects.Light} This Light object.
186190
*/

src/gameobjects/lights/LightsManager.js

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ var Utils = require('../../renderer/webgl/Utils');
1212
/**
1313
* @callback LightForEach
1414
*
15-
* @param {Phaser.GameObjects.Light} light - [description]
15+
* @param {Phaser.GameObjects.Light} light - The Light.
1616
*/
1717

1818
/**
1919
* @classdesc
20-
* [description]
20+
* Manages Lights for a Scene.
21+
*
22+
* Affects the rendering of Game Objects using the `Light2D` pipeline.
2123
*
2224
* @class LightsManager
2325
* @memberOf Phaser.GameObjects
@@ -31,7 +33,9 @@ var LightsManager = new Class({
3133
function LightsManager ()
3234
{
3335
/**
34-
* [description]
36+
* The pool of Lights.
37+
*
38+
* Used to recycle removed Lights for a more efficient use of memory.
3539
*
3640
* @name Phaser.GameObjects.LightsManager#lightPool
3741
* @type {Phaser.GameObjects.Light[]}
@@ -41,7 +45,7 @@ var LightsManager = new Class({
4145
this.lightPool = [];
4246

4347
/**
44-
* [description]
48+
* The Lights in the Scene.
4549
*
4650
* @name Phaser.GameObjects.LightsManager#lights
4751
* @type {Phaser.GameObjects.Light[]}
@@ -51,7 +55,9 @@ var LightsManager = new Class({
5155
this.lights = [];
5256

5357
/**
54-
* [description]
58+
* Lights that have been culled from a Camera's viewport.
59+
*
60+
* Lights in this list will not be rendered.
5561
*
5662
* @name Phaser.GameObjects.LightsManager#culledLights
5763
* @type {Phaser.GameObjects.Light[]}
@@ -61,7 +67,7 @@ var LightsManager = new Class({
6167
this.culledLights = [];
6268

6369
/**
64-
* [description]
70+
* The ambient color.
6571
*
6672
* @name Phaser.GameObjects.LightsManager#ambientColor
6773
* @type {{ r: float, g: float, b: float }}
@@ -70,7 +76,7 @@ var LightsManager = new Class({
7076
this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 };
7177

7278
/**
73-
* [description]
79+
* Whether the Lights Manager is enabled.
7480
*
7581
* @name Phaser.GameObjects.LightsManager#active
7682
* @type {boolean}
@@ -81,7 +87,7 @@ var LightsManager = new Class({
8187
},
8288

8389
/**
84-
* [description]
90+
* Enable the Lights Manager.
8591
*
8692
* @method Phaser.GameObjects.LightsManager#enable
8793
* @since 3.0.0
@@ -96,7 +102,7 @@ var LightsManager = new Class({
96102
},
97103

98104
/**
99-
* [description]
105+
* Disable the Lights Manager.
100106
*
101107
* @method Phaser.GameObjects.LightsManager#disable
102108
* @since 3.0.0
@@ -111,14 +117,16 @@ var LightsManager = new Class({
111117
},
112118

113119
/**
114-
* [description]
120+
* Cull any Lights that aren't visible to the given Camera.
121+
*
122+
* Culling Lights improves performance by ensuring that only Lights within a Camera's viewport are rendered.
115123
*
116124
* @method Phaser.GameObjects.LightsManager#cull
117125
* @since 3.0.0
118126
*
119-
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
127+
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to cull Lights for.
120128
*
121-
* @return {Phaser.GameObjects.Light[]} [description]
129+
* @return {Phaser.GameObjects.Light[]} The culled Lights.
122130
*/
123131
cull: function (camera)
124132
{
@@ -156,12 +164,12 @@ var LightsManager = new Class({
156164
},
157165

158166
/**
159-
* [description]
167+
* Iterate over each Light with a callback.
160168
*
161169
* @method Phaser.GameObjects.LightsManager#forEachLight
162170
* @since 3.0.0
163171
*
164-
* @param {LightForEach} callback - [description]
172+
* @param {LightForEach} callback - The callback that is called with each Light.
165173
*
166174
* @return {Phaser.GameObjects.LightsManager} This Lights Manager object.
167175
*/
@@ -184,12 +192,12 @@ var LightsManager = new Class({
184192
},
185193

186194
/**
187-
* [description]
195+
* Set the ambient light color.
188196
*
189197
* @method Phaser.GameObjects.LightsManager#setAmbientColor
190198
* @since 3.0.0
191199
*
192-
* @param {number} rgb - [description]
200+
* @param {number} rgb - The integer RGB color of the ambient light.
193201
*
194202
* @return {Phaser.GameObjects.LightsManager} This Lights Manager object.
195203
*/
@@ -210,39 +218,39 @@ var LightsManager = new Class({
210218
* @method Phaser.GameObjects.LightsManager#getMaxVisibleLights
211219
* @since 3.0.0
212220
*
213-
* @return {integer} [description]
221+
* @return {integer} The maximum number of Lights allowed to appear at once.
214222
*/
215223
getMaxVisibleLights: function ()
216224
{
217225
return 10;
218226
},
219227

220228
/**
221-
* [description]
229+
* Get the number of Lights managed by this Lights Manager.
222230
*
223231
* @method Phaser.GameObjects.LightsManager#getLightCount
224232
* @since 3.0.0
225233
*
226-
* @return {integer} [description]
234+
* @return {integer} The number of Lights managed by this Lights Manager.
227235
*/
228236
getLightCount: function ()
229237
{
230238
return this.lights.length;
231239
},
232240

233241
/**
234-
* [description]
242+
* Add a Light.
235243
*
236244
* @method Phaser.GameObjects.LightsManager#addLight
237245
* @since 3.0.0
238246
*
239-
* @param {number} x - [description]
240-
* @param {number} y - [description]
241-
* @param {number} radius - [description]
242-
* @param {number} rgb - [description]
243-
* @param {number} intensity - [description]
247+
* @param {number} x - The horizontal position of the Light.
248+
* @param {number} y - The vertical position of the Light.
249+
* @param {number} radius - The radius of the Light.
250+
* @param {number} rgb - The integer RGB color of the light.
251+
* @param {number} intensity - The intensity of the Light.
244252
*
245-
* @return {Phaser.GameObjects.Light} [description]
253+
* @return {Phaser.GameObjects.Light} The Light that was added.
246254
*/
247255
addLight: function (x, y, radius, rgb, intensity)
248256
{
@@ -274,12 +282,12 @@ var LightsManager = new Class({
274282
},
275283

276284
/**
277-
* [description]
285+
* Remove a Light.
278286
*
279287
* @method Phaser.GameObjects.LightsManager#removeLight
280288
* @since 3.0.0
281289
*
282-
* @param {Phaser.GameObjects.Light} light - [description]
290+
* @param {Phaser.GameObjects.Light} light - The Light to remove.
283291
*
284292
* @return {Phaser.GameObjects.LightsManager} This Lights Manager object.
285293
*/
@@ -297,7 +305,10 @@ var LightsManager = new Class({
297305
},
298306

299307
/**
300-
* [description]
308+
* Shut down the Lights Manager.
309+
*
310+
* Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and
311+
* culled Lights.
301312
*
302313
* @method Phaser.GameObjects.LightsManager#shutdown
303314
* @since 3.0.0
@@ -315,7 +326,9 @@ var LightsManager = new Class({
315326
},
316327

317328
/**
318-
* [description]
329+
* Destroy the Lights Manager.
330+
*
331+
* Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}.
319332
*
320333
* @method Phaser.GameObjects.LightsManager#destroy
321334
* @since 3.0.0

src/gameobjects/lights/LightsPlugin.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,30 @@ var PluginCache = require('../../plugins/PluginCache');
1010

1111
/**
1212
* @classdesc
13-
* [description]
13+
* A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for the Light2D pipeline.
14+
*
15+
* Available from within a Scene via `this.lights`.
16+
*
17+
* Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method:
18+
*
19+
* ```javascript
20+
* // Create a Light at [400, 300] and a radius of 200.
21+
* this.lights.addLight(400, 300, 200);
22+
* ```
23+
*
24+
* For Game Objects to be affected by the Lights when rendered, you will need to set them to use the `Light2D` pipeline like so:
25+
*
26+
* ```javascript
27+
* sprite.setPipeline('Light2D');
28+
* ```
1429
*
1530
* @class LightsPlugin
1631
* @extends Phaser.GameObjects.LightsManager
1732
* @memberOf Phaser.GameObjects
1833
* @constructor
1934
* @since 3.0.0
2035
*
21-
* @param {Phaser.Scene} scene - [description]
36+
* @param {Phaser.Scene} scene - The Scene that this Lights Plugin belongs to.
2237
*/
2338
var LightsPlugin = new Class({
2439

@@ -29,7 +44,7 @@ var LightsPlugin = new Class({
2944
function LightsPlugin (scene)
3045
{
3146
/**
32-
* [description]
47+
* A reference to the Scene that this Lights Plugin belongs to.
3348
*
3449
* @name Phaser.GameObjects.LightsPlugin#scene
3550
* @type {Phaser.Scene}
@@ -38,7 +53,7 @@ var LightsPlugin = new Class({
3853
this.scene = scene;
3954

4055
/**
41-
* [description]
56+
* A reference to the Scene's systems.
4257
*
4358
* @name Phaser.GameObjects.LightsPlugin#systems
4459
* @type {Phaser.Scenes.Systems}
@@ -55,7 +70,7 @@ var LightsPlugin = new Class({
5570
},
5671

5772
/**
58-
* [description]
73+
* Boot the Lights Plugin.
5974
*
6075
* @method Phaser.GameObjects.LightsPlugin#boot
6176
* @since 3.0.0
@@ -69,7 +84,9 @@ var LightsPlugin = new Class({
6984
},
7085

7186
/**
72-
* [description]
87+
* Destroy the Lights Plugin.
88+
*
89+
* Cleans up all references.
7390
*
7491
* @method Phaser.GameObjects.LightsPlugin#destroy
7592
* @since 3.0.0

0 commit comments

Comments
 (0)