Skip to content

Commit ef87b33

Browse files
committed
Added jsdocs
1 parent ae3cd50 commit ef87b33

5 files changed

Lines changed: 230 additions & 60 deletions

File tree

src/gameobjects/DisplayList.js

Lines changed: 84 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ var List = require('../structs/List');
99
var PluginManager = require('../plugins/PluginManager');
1010
var StableSort = require('../utils/array/StableSort');
1111

12+
/**
13+
* @classdesc
14+
* [description]
15+
*
16+
* @class DisplayList
17+
* @extends Phaser.Structs.List
18+
* @memberOf Phaser.GameObjects
19+
* @constructor
20+
* @since 3.0.0
21+
*
22+
* @param {Phaser.Scene} scene - [description]
23+
*/
1224
var DisplayList = new Class({
1325

1426
Extends: List,
@@ -19,10 +31,32 @@ var DisplayList = new Class({
1931
{
2032
List.call(this, scene);
2133

34+
/**
35+
* [description]
36+
*
37+
* @name Phaser.GameObjects.DisplayList#sortChildrenFlag
38+
* @type {boolean}
39+
* @default false
40+
* @since 3.0.0
41+
*/
2242
this.sortChildrenFlag = false;
2343

44+
/**
45+
* [description]
46+
*
47+
* @name Phaser.GameObjects.DisplayList#scene
48+
* @type {Phaser.Scene}
49+
* @since 3.0.0
50+
*/
2451
this.scene = scene;
2552

53+
/**
54+
* [description]
55+
*
56+
* @name Phaser.GameObjects.DisplayList#systems
57+
* @type {Phaser.Scenes.Systems}
58+
* @since 3.0.0
59+
*/
2660
this.systems = scene.sys;
2761

2862
if (!scene.sys.settings.isBooted)
@@ -31,6 +65,12 @@ var DisplayList = new Class({
3165
}
3266
},
3367

68+
/**
69+
* [description]
70+
*
71+
* @method Phaser.GameObjects.DisplayList#boot
72+
* @since 3.0.0
73+
*/
3474
boot: function ()
3575
{
3676
var eventEmitter = this.systems.events;
@@ -39,13 +79,23 @@ var DisplayList = new Class({
3979
eventEmitter.on('destroy', this.destroy, this);
4080
},
4181

42-
// Force a sort of the display list on the next call to process
82+
/**
83+
* Force a sort of the display list on the next call to depthSort.
84+
*
85+
* @method Phaser.GameObjects.DisplayList#queueDepthSort
86+
* @since 3.0.0
87+
*/
4388
queueDepthSort: function ()
4489
{
4590
this.sortChildrenFlag = true;
4691
},
4792

48-
// Immediately sorts the display list if the flag is set
93+
/**
94+
* Immediately sorts the display list if the flag is set.
95+
*
96+
* @method Phaser.GameObjects.DisplayList#depthSort
97+
* @since 3.0.0
98+
*/
4999
depthSort: function ()
50100
{
51101
if (this.sortChildrenFlag)
@@ -56,13 +106,33 @@ var DisplayList = new Class({
56106
}
57107
},
58108

109+
/**
110+
* [description]
111+
*
112+
* @method Phaser.GameObjects.DisplayList#sortByDepth
113+
* @since 3.0.0
114+
*
115+
* @param {Phaser.GameObjects.GameObject} childA - [description]
116+
* @param {Phaser.GameObjects.GameObject} childB - [description]
117+
*
118+
* @return {integer} [description]
119+
*/
59120
sortByDepth: function (childA, childB)
60121
{
61122
return childA._depth - childB._depth;
62123
},
63124

64-
// Given an array of Game Objects, sort the array and return it,
65-
// so that the objects are in index order with the lowest at the bottom.
125+
/**
126+
* Given an array of Game Objects, sort the array and return it,
127+
* so that the objects are in index order with the lowest at the bottom.
128+
*
129+
* @method Phaser.GameObjects.DisplayList#sortGameObjects
130+
* @since 3.0.0
131+
*
132+
* @param {Phaser.GameObjects.GameObject[]} gameObjects - [description]
133+
*
134+
* @return {array} [description]
135+
*/
66136
sortGameObjects: function (gameObjects)
67137
{
68138
if (gameObjects === undefined) { gameObjects = this.list; }
@@ -72,7 +142,16 @@ var DisplayList = new Class({
72142
return gameObjects.sort(this.sortIndexHandler.bind(this));
73143
},
74144

75-
// Note that the given array is sorted in place, even though it isn't returned directly it will still be updated.
145+
/**
146+
* Note that the given array is sorted in place, even though it isn't returned directly it will still be updated.
147+
*
148+
* @method Phaser.GameObjects.DisplayList#getTopGameObject
149+
* @since 3.0.0
150+
*
151+
* @param {Phaser.GameObjects.GameObject[]} gameObjects - [description]
152+
*
153+
* @return {Phaser.GameObjects.GameObject} The top-most Game Object on the Display List.
154+
*/
76155
getTopGameObject: function (gameObjects)
77156
{
78157
this.sortGameObjects(gameObjects);

src/gameobjects/UpdateList.js

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,108 @@
55
*/
66

77
var Class = require('../utils/Class');
8+
var PluginManager = require('../plugins/PluginManager');
89

10+
/**
11+
* @classdesc
12+
* [description]
13+
*
14+
* @class UpdateList
15+
* @memberOf Phaser.GameObjects
16+
* @constructor
17+
* @since 3.0.0
18+
*
19+
* @param {Phaser.Scene} scene - [description]
20+
*/
921
var UpdateList = new Class({
1022

1123
initialize:
1224

13-
function UpdateList ()
25+
function UpdateList (scene)
1426
{
27+
/**
28+
* [description]
29+
*
30+
* @name Phaser.GameObjects.UpdateList#scene
31+
* @type {Phaser.Scene}
32+
* @since 3.0.0
33+
*/
34+
this.scene = scene;
35+
36+
/**
37+
* [description]
38+
*
39+
* @name Phaser.GameObjects.UpdateList#systems
40+
* @type {Phaser.Scenes.Systems}
41+
* @since 3.0.0
42+
*/
43+
this.systems = scene.sys;
44+
45+
if (!scene.sys.settings.isBooted)
46+
{
47+
scene.sys.events.once('boot', this.boot, this);
48+
}
49+
50+
/**
51+
* [description]
52+
*
53+
* @name Phaser.GameObjects.UpdateList#_list
54+
* @type {array}
55+
* @private
56+
* @default []
57+
* @since 3.0.0
58+
*/
1559
this._list = [];
60+
61+
/**
62+
* [description]
63+
*
64+
* @name Phaser.GameObjects.UpdateList#_pendingInsertion
65+
* @type {array}
66+
* @private
67+
* @default []
68+
* @since 3.0.0
69+
*/
1670
this._pendingInsertion = [];
71+
72+
/**
73+
* [description]
74+
*
75+
* @name Phaser.GameObjects.UpdateList#_pendingRemoval
76+
* @type {array}
77+
* @private
78+
* @default []
79+
* @since 3.0.0
80+
*/
1781
this._pendingRemoval = [];
1882
},
1983

84+
/**
85+
* [description]
86+
*
87+
* @method Phaser.GameObjects.UpdateList#boot
88+
* @since 3.0.0
89+
*/
90+
boot: function ()
91+
{
92+
var eventEmitter = this.systems.events;
93+
94+
eventEmitter.on('preupdate', this.preUpdate, this);
95+
eventEmitter.on('update', this.update, this);
96+
eventEmitter.on('shutdown', this.shutdown, this);
97+
eventEmitter.on('destroy', this.destroy, this);
98+
},
99+
100+
/**
101+
* [description]
102+
*
103+
* @method Phaser.GameObjects.UpdateList#add
104+
* @since 3.0.0
105+
*
106+
* @param {Phaser.GameObjects.GameObject} child - [description]
107+
*
108+
* @return {Phaser.GameObjects.GameObject} [description]
109+
*/
20110
add: function (child)
21111
{
22112
// Is child already in this list?
@@ -29,6 +119,15 @@ var UpdateList = new Class({
29119
return child;
30120
},
31121

122+
/**
123+
* [description]
124+
*
125+
* @method Phaser.GameObjects.UpdateList#preUpdate
126+
* @since 3.0.0
127+
*
128+
* @param {number} time - [description]
129+
* @param {number} delta - [description]
130+
*/
32131
preUpdate: function (time, delta)
33132
{
34133
var toRemove = this._pendingRemoval.length;
@@ -67,6 +166,15 @@ var UpdateList = new Class({
67166
this._pendingInsertion.length = 0;
68167
},
69168

169+
/**
170+
* [description]
171+
*
172+
* @method Phaser.GameObjects.UpdateList#update
173+
* @since 3.0.0
174+
*
175+
* @param {number} time - [description]
176+
* @param {number} delta - [description]
177+
*/
70178
update: function (time, delta)
71179
{
72180
for (var i = 0; i < this._list.length; i++)
@@ -80,6 +188,16 @@ var UpdateList = new Class({
80188
}
81189
},
82190

191+
/**
192+
* [description]
193+
*
194+
* @method Phaser.GameObjects.UpdateList#remove
195+
* @since 3.0.0
196+
*
197+
* @param {Phaser.GameObjects.GameObject} child - [description]
198+
*
199+
* @return {Phaser.GameObjects.GameObject} [description]
200+
*/
83201
remove: function (child)
84202
{
85203
var index = this._list.indexOf(child);
@@ -92,6 +210,14 @@ var UpdateList = new Class({
92210
return child;
93211
},
94212

213+
/**
214+
* [description]
215+
*
216+
* @method Phaser.GameObjects.UpdateList#removeAll
217+
* @since 3.0.0
218+
*
219+
* @return {Phaser.GameObjects.UpdateList} The UpdateList object.
220+
*/
95221
removeAll: function ()
96222
{
97223
var i = this._list.length;
@@ -104,6 +230,12 @@ var UpdateList = new Class({
104230
return this;
105231
},
106232

233+
/**
234+
* [description]
235+
*
236+
* @method Phaser.GameObjects.UpdateList#shutdown
237+
* @since 3.0.0
238+
*/
107239
shutdown: function ()
108240
{
109241
this.removeAll();
@@ -113,11 +245,23 @@ var UpdateList = new Class({
113245
this._pendingInsertion.length = 0;
114246
},
115247

248+
/**
249+
* [description]
250+
*
251+
* @method Phaser.GameObjects.UpdateList#destroy
252+
* @since 3.0.0
253+
*/
116254
destroy: function ()
117255
{
118256
this.shutdown();
257+
258+
this.scene = undefined;
259+
this.systems = undefined;
260+
119261
}
120262

121263
});
122264

265+
PluginManager.register('UpdateList', UpdateList, 'updateList');
266+
123267
module.exports = UpdateList;

0 commit comments

Comments
 (0)