Skip to content

Commit 26a496a

Browse files
committed
Added jsdocs
1 parent a4381d6 commit 26a496a

7 files changed

Lines changed: 219 additions & 21 deletions

File tree

src/gameobjects/GameObjectCreator.js

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,80 @@
11
var Class = require('../utils/Class');
22
var PluginManager = require('../plugins/PluginManager');
33

4+
/**
5+
* The Game Object Creator is a Scene plugin that allows you to quickly create many common
6+
* types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically
7+
* added to the Scene.
8+
*
9+
* Game Objects directly register themselves with the Creator and inject their own creation
10+
* methods into the class.
11+
*
12+
* @class GameObjectCreator
13+
* @memberOf Phaser.GameObjects
14+
* @constructor
15+
* @since 3.0.0
16+
*
17+
* @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs.
18+
*/
419
var GameObjectCreator = new Class({
520

621
initialize:
722

823
function GameObjectCreator (scene)
924
{
10-
// The Scene that owns this plugin
25+
/**
26+
* The Scene to which this Game Object Creator belongs.
27+
*
28+
* @name Phaser.GameObjects.GameObjectCreator#scene
29+
* @type {Phaser.Scene}
30+
* @protected
31+
* @since 3.0.0
32+
*/
1133
this.scene = scene;
1234

35+
/**
36+
* A reference to the Scene.Systems.
37+
*
38+
* @name Phaser.GameObjects.GameObjectCreator#systems
39+
* @type {Phaser.Scenes.Systems}
40+
* @protected
41+
* @since 3.0.0
42+
*/
1343
this.systems = scene.sys;
1444

1545
if (!scene.sys.settings.isBooted)
1646
{
1747
scene.sys.events.once('boot', this.boot, this);
1848
}
1949

50+
/**
51+
* A reference to the Scene Display List.
52+
*
53+
* @name Phaser.GameObjects.GameObjectCreator#displayList
54+
* @type {Phaser.GameObjects.DisplayList}
55+
* @protected
56+
* @since 3.0.0
57+
*/
2058
this.displayList;
59+
60+
/**
61+
* A reference to the Scene Update List.
62+
*
63+
* @name Phaser.GameObjects.GameObjectCreator#updateList;
64+
* @type {Phaser.GameObjects.UpdateList}
65+
* @protected
66+
* @since 3.0.0
67+
*/
2168
this.updateList;
2269
},
2370

71+
/**
72+
* Boots the plugin.
73+
*
74+
* @method Phaser.GameObjects.GameObjectCreator#boot
75+
* @private
76+
* @since 3.0.0
77+
*/
2478
boot: function ()
2579
{
2680
this.displayList = this.systems.displayList;
@@ -32,11 +86,22 @@ var GameObjectCreator = new Class({
3286
eventEmitter.on('destroy', this.destroy, this);
3387
},
3488

89+
/**
90+
* Shuts this plugin down.
91+
*
92+
* @method Phaser.GameObjects.GameObjectCreator#shutdown
93+
* @since 3.0.0
94+
*/
3595
shutdown: function ()
3696
{
37-
// TODO
3897
},
3998

99+
/**
100+
* Destroys this plugin.
101+
*
102+
* @method Phaser.GameObjects.GameObjectCreator#destroy
103+
* @since 3.0.0
104+
*/
40105
destroy: function ()
41106
{
42107
this.scene = null;

src/gameobjects/GameObjectFactory.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ var Class = require('../utils/Class');
22
var PluginManager = require('../plugins/PluginManager');
33

44
/**
5-
* [description]
5+
* The Game Object Factory is a Scene plugin that allows you to quickly create many common
6+
* types of Game Objects and have them automatically registered with the Scene.
7+
*
8+
* Game Objects directly register themselves with the Factory and inject their own creation
9+
* methods into the class.
610
*
711
* @class GameObjectFactory
812
* @memberOf Phaser.GameObjects
913
* @constructor
1014
* @since 3.0.0
1115
*
12-
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs.
16+
* @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs.
1317
*/
1418
var GameObjectFactory = new Class({
1519

@@ -18,8 +22,7 @@ var GameObjectFactory = new Class({
1822
function GameObjectFactory (scene)
1923
{
2024
/**
21-
* The Scene to which this Game Object belongs.
22-
* Game Objects can only belong to one Scene.
25+
* The Scene to which this Game Object Factory belongs.
2326
*
2427
* @name Phaser.GameObjects.GameObjectFactory#scene
2528
* @type {Phaser.Scene}
@@ -43,8 +46,24 @@ var GameObjectFactory = new Class({
4346
scene.sys.events.once('boot', this.boot, this);
4447
}
4548

49+
/**
50+
* A reference to the Scene Display List.
51+
*
52+
* @name Phaser.GameObjects.GameObjectFactory#displayList
53+
* @type {Phaser.GameObjects.DisplayList}
54+
* @protected
55+
* @since 3.0.0
56+
*/
4657
this.displayList;
4758

59+
/**
60+
* A reference to the Scene Update List.
61+
*
62+
* @name Phaser.GameObjects.GameObjectFactory#updateList;
63+
* @type {Phaser.GameObjects.UpdateList}
64+
* @protected
65+
* @since 3.0.0
66+
*/
4867
this.updateList;
4968
},
5069

src/gameobjects/mesh/Mesh.js

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,42 @@
1-
21
var Class = require('../../utils/Class');
3-
var GameObject = require('../GameObject');
42
var Components = require('../components');
3+
var GameObject = require('../GameObject');
54
var MeshRender = require('./MeshRender');
65

6+
/**
7+
* A Mesh Game Object.
8+
*
9+
* @class Mesh
10+
* @extends Phaser.GameObjects.GameObject
11+
* @memberOf Phaser.GameObjects
12+
* @constructor
13+
* @webglOnly
14+
* @since 3.0.0
15+
*
16+
* @extends Phaser.GameObjects.Components.Alpha
17+
* @extends Phaser.GameObjects.Components.BlendMode
18+
* @extends Phaser.GameObjects.Components.Depth
19+
* @extends Phaser.GameObjects.Components.Flip
20+
* @extends Phaser.GameObjects.Components.GetBounds
21+
* @extends Phaser.GameObjects.Components.Origin
22+
* @extends Phaser.GameObjects.Components.Pipeline
23+
* @extends Phaser.GameObjects.Components.ScaleMode
24+
* @extends Phaser.GameObjects.Components.Size
25+
* @extends Phaser.GameObjects.Components.Texture
26+
* @extends Phaser.GameObjects.Components.Transform
27+
* @extends Phaser.GameObjects.Components.Visible
28+
* @extends Phaser.GameObjects.Components.ScrollFactor
29+
*
30+
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
31+
* @param {number} x - The horizontal position of this Game Object in the world.
32+
* @param {number} y - The vertical position of this Game Object in the world.
33+
* @param {array} vertices - [description]
34+
* @param {array} uv - [description]
35+
* @param {array} colors - [description]
36+
* @param {array} alphas - [description]
37+
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
38+
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
39+
*/
740
var Mesh = new Class({
841

942
Extends: GameObject,
@@ -39,19 +72,19 @@ var Mesh = new Class({
3972

4073
if (vertices.length !== uv.length)
4174
{
42-
throw new Error('Phaser: Vertex count must match UV count');
75+
throw new Error('Mesh Vertex count must match UV count');
4376
}
4477

4578
var verticesUB = (vertices.length / 2) | 0;
4679

4780
if (colors.length > 0 && colors.length < verticesUB)
4881
{
49-
throw new Error('Phaser: Color count must match Vertex count');
82+
throw new Error('Mesh Color count must match Vertex count');
5083
}
5184

5285
if (alphas.length > 0 && alphas.length < verticesUB)
5386
{
54-
throw new Error('Phaser: Alpha count must match Vertex count');
87+
throw new Error('Mesh Alpha count must match Vertex count');
5588
}
5689

5790
var i;
@@ -72,9 +105,40 @@ var Mesh = new Class({
72105
}
73106
}
74107

108+
/**
109+
* [description]
110+
*
111+
* @name Phaser.GameObjects.Mesh#vertices
112+
* @type {Float32Array}
113+
* @since 3.0.0
114+
*/
75115
this.vertices = new Float32Array(vertices);
116+
117+
/**
118+
* [description]
119+
*
120+
* @name Phaser.GameObjects.Mesh#uv
121+
* @type {Float32Array}
122+
* @since 3.0.0
123+
*/
76124
this.uv = new Float32Array(uv);
125+
126+
/**
127+
* [description]
128+
*
129+
* @name Phaser.GameObjects.Mesh#colors
130+
* @type {Uint32Array}
131+
* @since 3.0.0
132+
*/
77133
this.colors = new Uint32Array(colors);
134+
135+
/**
136+
* [description]
137+
*
138+
* @name Phaser.GameObjects.Mesh#alphas
139+
* @type {Float32Array}
140+
* @since 3.0.0
141+
*/
78142
this.alphas = new Float32Array(alphas);
79143
}
80144

src/gameobjects/mesh/MeshCanvasRenderer.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/**
2+
* This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects.
3+
*
4+
* @method Phaser.GameObjects.Mesh#renderCanvas
5+
* @since 3.0.0
6+
* @private
7+
*
8+
* @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
9+
* @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call.
10+
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
11+
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
12+
*/
113
var MeshCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
214
{
315
};

src/gameobjects/mesh/MeshCreator.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
44
var GetValue = require('../../utils/object/GetValue');
55
var Mesh = require('./Mesh');
66

7-
// When registering a factory function 'this' refers to the GameObjectCreator context.
8-
7+
/**
8+
* Creates a new Mesh Game Object and returns it.
9+
*
10+
* Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser.
11+
*
12+
* @method Phaser.GameObjects.GameObjectCreator#mesh
13+
* @since 3.0.0
14+
*
15+
* @param {object} config - [description]
16+
*
17+
* @return {Phaser.GameObjects.Mesh} The Game Object that was created.
18+
*/
919
GameObjectCreator.register('mesh', function (config)
1020
{
1121
var key = GetAdvancedValue(config, 'key', null);
@@ -21,3 +31,5 @@ GameObjectCreator.register('mesh', function (config)
2131

2232
return mesh;
2333
});
34+
35+
// When registering a factory function 'this' refers to the GameObjectCreator context.
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
var Mesh = require('./Mesh');
22
var GameObjectFactory = require('../GameObjectFactory');
33

4-
// When registering a factory function 'this' refers to the GameObjectFactory context.
5-
//
6-
// There are several properties available to use:
7-
//
8-
// this.scene - a reference to the Scene that owns the GameObjectFactory
9-
// this.displayList - a reference to the Display List the Scene owns
10-
// this.updateList - a reference to the Update List the Scene owns
11-
4+
/**
5+
* Creates a new Mesh Game Object and adds it to the Scene.
6+
*
7+
* Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser.
8+
*
9+
* @method Phaser.GameObjects.GameObjectFactory#mesh
10+
* @webglOnly
11+
* @since 3.0.0
12+
*
13+
*
14+
* @return {Phaser.GameObjects.Mesh} The Game Object that was created.
15+
*/
1216
if (WEBGL_RENDERER)
1317
{
1418
GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame)
1519
{
1620
return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, key, frame));
1721
});
1822
}
23+
24+
// When registering a factory function 'this' refers to the GameObjectFactory context.
25+
//
26+
// There are several properties available to use:
27+
//
28+
// this.scene - a reference to the Scene that owns the GameObjectFactory
29+
// this.displayList - a reference to the Display List the Scene owns
30+
// this.updateList - a reference to the Update List the Scene owns

src/gameobjects/mesh/MeshWebGLRenderer.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
var GameObject = require('../GameObject');
22

3+
/**
4+
* Renders this Game Object with the WebGL Renderer to the given Camera.
5+
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
6+
* This method should not be called directly. It is a utility function of the Render module.
7+
*
8+
* @method Phaser.GameObjects.Mesh#renderWebGL
9+
* @since 3.0.0
10+
* @private
11+
*
12+
* @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer.
13+
* @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call.
14+
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
15+
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
16+
*/
317
var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
418
{
519
if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)))

0 commit comments

Comments
 (0)