Skip to content

Commit fa13b59

Browse files
committed
Add more callbacks
1 parent 1e8311e commit fa13b59

8 files changed

Lines changed: 74 additions & 19 deletions

File tree

src/loader/File.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ var MergeXHRSettings = require('./MergeXHRSettings');
1212
var XHRLoader = require('./XHRLoader');
1313
var XHRSettings = require('./XHRSettings');
1414

15+
/**
16+
* @callback FileProcessCallback
17+
*
18+
* @param {Phaser.Loader.File} file - [description]
19+
*/
20+
1521
/**
1622
* @classdesc
1723
* [description]
@@ -31,7 +37,7 @@ var File = new Class({
3137
{
3238
/**
3339
* The file type string (image, json, etc) for sorting within the Loader.
34-
*
40+
*
3541
* @name Phaser.Loader.File#type
3642
* @type {string}
3743
* @since 3.0.0
@@ -219,7 +225,7 @@ var File = new Class({
219225
*
220226
* @method Phaser.Loader.File#setLinkFile
221227
* @since 3.0.0
222-
*
228+
*
223229
* @param {Phaser.Loader.File} fileB - The linked file.
224230
* @param {string} linkType - The type of association.
225231
*/
@@ -350,7 +356,7 @@ var File = new Class({
350356
* @method Phaser.Loader.File#onProcess
351357
* @since 3.0.0
352358
*
353-
* @param {function} callback - The callback to invoke to process this File.
359+
* @param {FileProcessCallback} callback - The callback to invoke to process this File.
354360
*/
355361
onProcess: function (callback)
356362
{

src/loader/filetypes/AudioFile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var AudioFile = new Class({
6262
* @method Phaser.Loader.FileTypes.AudioFile#onProcess
6363
* @since 3.0.0
6464
*
65-
* @param {function} callback - [description]
65+
* @param {FileProcessCallback} callback - [description]
6666
*/
6767
onProcess: function (callback)
6868
{

src/physics/impact/components/Collides.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
var COLLIDES = require('../COLLIDES');
88

9+
/**
10+
* @callback CollideCallback
11+
*
12+
* @param {Phaser.Physics.Impact.Body} body - [description]
13+
* @param {Phaser.Physics.Impact.Body} other - [description]
14+
* @param {string} axis - [description]
15+
*/
16+
917
/**
1018
* [description]
1119
*
@@ -23,7 +31,7 @@ var Collides = {
2331
* @method Phaser.Physics.Impact.Components.Collides#setCollideCallback
2432
* @since 3.0.0
2533
*
26-
* @param {function} callback - [description]
34+
* @param {CollideCallback} callback - [description]
2735
* @param {object} scope - [description]
2836
*
2937
* @return {Phaser.GameObjects.GameObject} This Game Object.

src/sound/BaseSoundManager.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ var Class = require('../utils/Class');
77
var EventEmitter = require('eventemitter3');
88
var NOOP = require('../utils/NOOP');
99

10+
/**
11+
* @callback EachActiveSoundCallback
12+
*
13+
* @param {Phaser.Sound.BaseSoundManager} manager - [description]
14+
* @param {Phaser.Sound.BaseSound} sound - [description]
15+
* @param {number} index - [description]
16+
* @param {Phaser.Sound.BaseSound[]} sounds - [description]
17+
*/
18+
1019
/**
1120
* @classdesc
1221
* The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback.
@@ -466,17 +475,17 @@ var BaseSoundManager = new Class({
466475
* @private
467476
* @since 3.0.0
468477
*
469-
* @param {function} callbackfn - Callback function. (sound: ISound, index: number, array: ISound[]) => void
478+
* @param {EachActiveSoundCallback} callback - Callback function. (sound: ISound, index: number, array: ISound[]) => void
470479
* @param {object} [scope] - Callback context.
471480
*/
472-
forEachActiveSound: function (callbackfn, scope)
481+
forEachActiveSound: function (callback, scope)
473482
{
474483
var _this = this;
475484
this.sounds.forEach(function (sound, index)
476485
{
477486
if (!sound.pendingRemove)
478487
{
479-
callbackfn.call(scope || _this, sound, index, _this.sounds);
488+
callback.call(scope || _this, sound, index, _this.sounds);
480489
}
481490
});
482491
},

src/structs/List.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
var Class = require('../utils/Class');
88

9+
/**
10+
* @callback EachListCallback
11+
*
12+
* @param {any} item - [description]
13+
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child.
14+
*/
15+
916
/**
1017
* @classdesc
1118
* [description]
@@ -737,7 +744,7 @@ var List = new Class({
737744
* @method Phaser.Structs.List#each
738745
* @since 3.0.0
739746
*
740-
* @param {function} callback - The function to call.
747+
* @param {EachListCallback} callback - The function to call.
741748
* @param {object} [thisArg] - Value to use as `this` when executing callback.
742749
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child.
743750
*/

src/structs/Map.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66

77
var Class = require('../utils/Class');
88

9+
/**
10+
* @callback EachMapCallback
11+
*
12+
* @param {string} key - [description]
13+
* @param {any} entry - [description]
14+
*
15+
* @return {?boolean} [description]
16+
*/
17+
918
/**
1019
* @classdesc
1120
* The keys of a Map can be arbitrary values.
@@ -32,7 +41,7 @@ var Map = new Class({
3241
* [description]
3342
*
3443
* @name Phaser.Structs.Map#entries
35-
* @type {object}
44+
* @type {Object.<string, any>}
3645
* @default {}
3746
* @since 3.0.0
3847
*/
@@ -237,7 +246,7 @@ var Map = new Class({
237246
* @method Phaser.Structs.Map#each
238247
* @since 3.0.0
239248
*
240-
* @param {function} callback - [description]
249+
* @param {EachMapCallback} callback - [description]
241250
*
242251
* @return {Phaser.Structs.Map} This Map object.
243252
*/

src/structs/Set.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66

77
var Class = require('../utils/Class');
88

9+
/**
10+
* @callback EachSetCallback
11+
*
12+
* @param {any} entry - [description]
13+
* @param {number} index - [description]
14+
*
15+
* @return {?boolean} [description]
16+
*/
17+
918
/**
1019
* @classdesc
1120
* A Set is a collection of unique elements.
@@ -148,7 +157,7 @@ var Set = new Class({
148157
* @method Phaser.Structs.Set#each
149158
* @since 3.0.0
150159
*
151-
* @param {function} callback - [description]
160+
* @param {EachSetCallback} callback - [description]
152161
* @param {object} callbackScope - [description]
153162
*
154163
* @return {Phaser.Structs.Set} This Set object.
@@ -189,7 +198,7 @@ var Set = new Class({
189198
* @method Phaser.Structs.Set#iterate
190199
* @since 3.0.0
191200
*
192-
* @param {function} callback - [description]
201+
* @param {EachSetCallback} callback - [description]
193202
* @param {object} callbackScope - [description]
194203
*
195204
* @return {Phaser.Structs.Set} This Set object.

src/textures/TextureManager.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ var GetValue = require('../utils/object/GetValue');
1313
var Parser = require('./parsers');
1414
var Texture = require('./Texture');
1515

16+
/**
17+
* @callback EachTextureCallback
18+
*
19+
* @param {Phaser.Textures.Texture} texture - [description]
20+
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child.
21+
*/
22+
1623
/**
1724
* @classdesc
1825
* Textures are managed by the global TextureManager. This is a singleton class that is
@@ -163,7 +170,7 @@ var TextureManager = new Class({
163170
image.onload = function ()
164171
{
165172
var texture = _this.create(key, image);
166-
173+
167174
Parser.Image(texture, 0);
168175

169176
_this.emit('onload', key, texture);
@@ -187,7 +194,7 @@ var TextureManager = new Class({
187194
addImage: function (key, source, dataSource)
188195
{
189196
var texture = this.create(key, source);
190-
197+
191198
Parser.Image(texture, 0);
192199

193200
if (dataSource)
@@ -262,7 +269,7 @@ var TextureManager = new Class({
262269
addCanvas: function (key, source)
263270
{
264271
var texture = this.create(key, source);
265-
272+
266273
Parser.Canvas(texture, 0);
267274

268275
return texture;
@@ -386,7 +393,7 @@ var TextureManager = new Class({
386393

387394
/**
388395
* Adds a Sprite Sheet to this Texture Manager.
389-
*
396+
*
390397
* In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact
391398
* same size and cannot be trimmed or rotated.
392399
*
@@ -419,7 +426,7 @@ var TextureManager = new Class({
419426

420427
/**
421428
* Adds a Sprite Sheet to this Texture Manager, where the Sprite Sheet exists as a Frame within a Texture Atlas.
422-
*
429+
*
423430
* In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact
424431
* same size and cannot be trimmed or rotated.
425432
*
@@ -738,7 +745,7 @@ var TextureManager = new Class({
738745
* @method Phaser.Textures.TextureManager#each
739746
* @since 3.0.0
740747
*
741-
* @param {function} callback - The callback function to be sent the Textures.
748+
* @param {EachTextureCallback} callback - The callback function to be sent the Textures.
742749
* @param {object} scope - The value to use as `this` when executing the callback.
743750
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child.
744751
*/

0 commit comments

Comments
 (0)