Merge pull request #3425 from orblazer/fix-types

Add callbacks types
This commit is contained in:
Richard Davey 2018-03-19 23:02:37 +00:00 committed by GitHub
commit f4f88a6daa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 395 additions and 149 deletions

View file

@ -4,6 +4,12 @@
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @callback CallCallback
*
* @param {Phaser.GameObjects.GameObject} item - [description]
*/
/**
* Takes an array of objects and passes each of them to the given callback.
*
@ -11,7 +17,7 @@
* @since 3.0.0
*
* @param {array|Phaser.GameObjects.GameObject[]} items - The array of items to be updated by this action.
* @param {function} callback - The callback to be invoked. It will be passed just one argument: the item from the array.
* @param {CallCallback} callback - The callback to be invoked. It will be passed just one argument: the item from the array.
* @param {object} context - The scope in which the callback will be invoked.
*
* @return {array} The array of objects that was passed to this Action.

View file

@ -12,7 +12,7 @@
*
* @param {array} items - An array of Game Objects. The contents of this array are updated by this Action.
* @param {any} hitArea - [description]
* @param {function} hitAreaCallback - [description]
* @param {HitAreaCallback} hitAreaCallback - [description]
*
* @return {array} The array of Game Objects that was passed to this Action.
*/

View file

@ -18,6 +18,12 @@ var ValueToColor = require('../display/color/ValueToColor');
* @callback NOOP
*/
/**
* @callback BootCallback
*
* @param {Phaser.Game} game - [description]
*/
/**
* @typedef {object} FPSConfig
*
@ -86,8 +92,8 @@ var ValueToColor = require('../display/color/ValueToColor');
* @property {boolean} [powerPreference='default'] - "high-performance", "low-power" or "default"
* @property {string|number} [backgroundColor=0x000000] - [description]
* @property {object} [?callbacks] - [description]
* @property {function} [callbacks.preBoot=NOOP] - [description]
* @property {function} [callbacks.postBoot=NOOP] - [description]
* @property {BootCallback} [callbacks.preBoot=NOOP] - [description]
* @property {BootCallback} [callbacks.postBoot=NOOP] - [description]
* @property {LoaderConfig} [?loader] - [description]
* @property {object} [?images] - [description]
* @property {string} [images.default] - [description]

View file

@ -25,6 +25,10 @@ var TextureManager = require('../textures/TextureManager');
var TimeStep = require('./TimeStep');
var VisibilityHandler = require('./VisibilityHandler');
/**
* @callback GameStepCallback
*/
/**
* @classdesc
* The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible
@ -232,7 +236,7 @@ var Game = new Class({
* It is set automatically when the Game boot process has completed.
*
* @name Phaser.Game#onStepCallback
* @type {function}
* @type {GameStepCallback}
* @private
* @since 3.0.0
*/

View file

@ -20,6 +20,14 @@ var RequestAnimationFrame = require('../dom/RequestAnimationFrame');
// http://www.testufo.com/#test=animation-time-graph
/**
* @callback TimeStepCallback
*
* @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
* @param {number} average - The Delta Average.
* @param {number} interpolation - Interpolation - how far between what is expected and where we are?
*/
/**
* @classdesc
* [description]
@ -154,7 +162,7 @@ var TimeStep = new Class({
/**
* A callback to be invoked each time the Time Step steps.
*
* @property {function} callback
* @property {TimeStepCallback} callback
* @default NOOP
* @since 3.0.0
*/
@ -379,7 +387,7 @@ var TimeStep = new Class({
* @method Phaser.Boot.TimeStep#start
* @since 3.0.0
*
* @param {function} callback - The callback to be invoked each time the Time Step steps.
* @param {TimeStepCallback} callback - The callback to be invoked each time the Time Step steps.
*/
start: function (callback)
{

View file

@ -8,6 +8,13 @@ var Arne16 = require('./palettes/Arne16');
var CanvasPool = require('../display/canvas/CanvasPool');
var GetValue = require('../utils/object/GetValue');
/**
* @callback GenerateTextureRendererCallback
*
* @param {HTMLCanvasElement} canvas - [description]
* @param {CanvasRenderingContext2D} context - [description]
*/
/**
* @typedef {object} GenerateTextureConfig
*
@ -18,8 +25,8 @@ var GetValue = require('../utils/object/GetValue');
* @property {number} [pixelHeight=1] - [description]
* @property {boolean} [resizeCanvas=true] - [description]
* @property {boolean} [clearCanvas=true] - [description]
* @property {function} [preRender] - [description]
* @property {function} [postRender] - [description]
* @property {GenerateTextureRendererCallback} [preRender] - [description]
* @property {GenerateTextureRendererCallback} [postRender] - [description]
*/
/**

View file

@ -6,6 +6,15 @@
var Class = require('../utils/Class');
/**
* @callback DataEachCallback
*
* @param {any} parent - [description]
* @param {string} key - [description]
* @param {any} value - [description]
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the game object, key, and data.
*/
/**
* @classdesc
* The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin.
@ -199,7 +208,7 @@ var DataManager = new Class({
* @method Phaser.Data.DataManager#each
* @since 3.0.0
*
* @param {function} callback - The function to call.
* @param {DataEachCallback} callback - The function to call.
* @param {object} [scope] - Value to use as `this` when executing callback.
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the game object, key, and data.
*

View file

@ -6,6 +6,10 @@
var OS = require('../device/OS');
/**
* @callback ContentLoadedCallback
*/
/**
* Inspects the readyState of the document. If the document is already complete then it invokes the given callback.
* If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback.
@ -14,7 +18,7 @@ var OS = require('../device/OS');
* @function Phaser.DOM.DOMContentLoaded
* @since 3.0.0
*
* @param {function} callback - The callback to be invoked when the device is ready and the DOM content is loaded.
* @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded.
*/
var DOMContentLoaded = function (callback)
{

View file

@ -37,7 +37,7 @@ var RequestAnimationFrame = new Class({
* The callback to be invoked each step.
*
* @name Phaser.DOM.RequestAnimationFrame#callback
* @type {function}
* @type {FrameRequestCallback}
* @since 3.0.0
*/
this.callback = NOOP;
@ -89,7 +89,7 @@ var RequestAnimationFrame = new Class({
* Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame.
*
* @name Phaser.DOM.RequestAnimationFrame#step
* @type {function}
* @type {FrameRequestCallback}
* @since 3.0.0
*/
this.step = function step (timestamp)
@ -134,7 +134,7 @@ var RequestAnimationFrame = new Class({
* @method Phaser.DOM.RequestAnimationFrame#start
* @since 3.0.0
*
* @param {function} callback - The callback to invoke each step.
* @param {FrameRequestCallback} callback - The callback to invoke each step.
* @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available?
*/
start: function (callback, forceSetTimeOut)

View file

@ -254,7 +254,7 @@ var GameObject = new Class({
* @since 3.0.0
*
* @param {any} [shape] - A geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
* @param {function} [callback] - A callback to be invoked when the Game Object is interacted with.
* @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with.
* @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target?
*
* @return {Phaser.GameObjects.GameObject} This GameObject.

View file

@ -10,6 +10,20 @@ var GameObject = require('../../GameObject');
var GetBitmapTextSize = require('../GetBitmapTextSize');
var Render = require('./DynamicBitmapTextRender');
/**
* @callback DisplayCallback
*
* @param {object} display - [description]
* @param {{topLeft:number,topRight:number,bottomLeft:number,bottomRight:number}} display.tint - [description]
* @param {number} display.index - [description]
* @param {number} display.charCode - [description]
* @param {number} display.x - [description]
* @param {number} display.y - [description]
* @param {number} display.scale - [description]
* @param {number} display.rotation - [description]
* @param {[type]} display.data - [description]
*/
/**
* @classdesc
* [description]
@ -161,7 +175,7 @@ var DynamicBitmapText = new Class({
* [description]
*
* @name Phaser.GameObjects.DynamicBitmapText#displayCallback;
* @type {function}
* @type {DisplayCallback}
* @since 3.0.0
*/
this.displayCallback;
@ -192,7 +206,7 @@ var DynamicBitmapText = new Class({
* @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {DisplayCallback} callback - [description]
*
* @return {Phaser.GameObjects.DynamicBitmapText} This Game Object.
*/
@ -286,21 +300,6 @@ var DynamicBitmapText = new Class({
return this;
},
// {
// local: {
// x,
// y,
// width,
// height
// },
// global: {
// x,
// y,
// width,
// height
// }
// }
/**
* [description]
*

View file

@ -12,6 +12,13 @@ var Frame = require('../../textures/Frame');
var GameObject = require('../GameObject');
var List = require('../../structs/List');
/**
* @callback BlitterFromCallback
*
* @param {Phaser.GameObjects.Blitter} blitter - [description]
* @param {integer} index - [description]
*/
/**
* @classdesc
* A Blitter Game Object.
@ -144,7 +151,7 @@ var Blitter = new Class({
* @method Phaser.GameObjects.Blitter#createFromCallback
* @since 3.0.0
*
* @param {function} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob.
* @param {BlitterFromCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob.
* @param {integer} quantity - The quantity of Bob objects to create.
* @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture.
* @param {boolean} [visible=true] - [description]

View file

@ -9,6 +9,12 @@ var Light = require('./Light');
var LightPipeline = require('../../renderer/webgl/pipelines/ForwardDiffuseLightPipeline');
var Utils = require('../../renderer/webgl/Utils');
/**
* @callback LightForEach
*
* @param {Phaser.GameObjects.Light} light - [description]
*/
/**
* @classdesc
* [description]
@ -28,7 +34,7 @@ var LightsManager = new Class({
* [description]
*
* @name Phaser.GameObjects.LightsManager#lightPool
* @type {array}
* @type {Phaser.GameObjects.Light[]}
* @default []
* @since 3.0.0
*/
@ -38,7 +44,7 @@ var LightsManager = new Class({
* [description]
*
* @name Phaser.GameObjects.LightsManager#lights
* @type {array}
* @type {Phaser.GameObjects.Light[]}
* @default []
* @since 3.0.0
*/
@ -48,7 +54,7 @@ var LightsManager = new Class({
* [description]
*
* @name Phaser.GameObjects.LightsManager#culledLights
* @type {array}
* @type {Phaser.GameObjects.Light[]}
* @default []
* @since 3.0.0
*/
@ -155,7 +161,7 @@ var LightsManager = new Class({
* @method Phaser.GameObjects.LightsManager#forEachLight
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {LightForEach} callback - [description]
*
* @return {Phaser.GameObjects.LightsManager} This Lights Manager object.
*/

View file

@ -10,6 +10,29 @@ var GetEaseFunction = require('../../tweens/builders/GetEaseFunction');
var GetFastValue = require('../../utils/object/GetFastValue');
var Wrap = require('../../math/Wrap');
/**
* The returned value sets what the property will be at the START of the particles life, on emit.
* @callback EmitterOpOnEmitCallback
*
* @param {Phaser.GameObjects.Particles.Particle} particle - [description]
* @param {string} key - [description]
* @param {number} value - [description]
*
* @return {number} [description]
*/
/**
* The returned value updates the property for the duration of the particles life.
* @callback EmitterOpOnUpdateCallback
*
* @param {Phaser.GameObjects.Particles.Particle} particle - [description]
* @param {string} key - [description]
* @param {float} t - The T value (between 0 and 1)
* @param {number} value - [description]
*
* @return {number} [description]
*/
/**
* @classdesc
* [description]
@ -121,7 +144,7 @@ var EmitterOp = new Class({
* [description]
*
* @name Phaser.GameObjects.Particles.EmitterOp#onEmit
* @type {function}
* @type {EmitterOpOnEmitCallback}
* @since 3.0.0
*/
this.onEmit = this.defaultEmit;
@ -130,7 +153,7 @@ var EmitterOp = new Class({
* [description]
*
* @name Phaser.GameObjects.Particles.EmitterOp#onUpdate
* @type {function}
* @type {EmitterOpOnUpdateCallback}
* @since 3.0.0
*/
this.onUpdate = this.defaultUpdate;

View file

@ -21,6 +21,19 @@ var StableSort = require('../../utils/array/StableSort');
var Vector2 = require('../../math/Vector2');
var Wrap = require('../../math/Wrap');
/**
* @callback ParticleEmitterCallback
*
* @param {Phaser.GameObjects.Particles.Particle} particle - [description]
* @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - [description]
*/
/**
* @callback ParticleDeathCallback
*
* @param {Phaser.GameObjects.Particles.Particle} particle - [description]
*/
/**
* @classdesc
* [description]
@ -400,7 +413,7 @@ var ParticleEmitter = new Class({
* [description]
*
* @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback
* @type {?function}
* @type {?ParticleEmitterCallback}
* @default null
* @since 3.0.0
*/
@ -410,7 +423,7 @@ var ParticleEmitter = new Class({
* [description]
*
* @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope
* @type {?object}
* @type {?any}
* @default null
* @since 3.0.0
*/
@ -420,7 +433,7 @@ var ParticleEmitter = new Class({
* [description]
*
* @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback
* @type {?function}
* @type {?ParticleDeathCallback}
* @default null
* @since 3.0.0
*/
@ -430,7 +443,7 @@ var ParticleEmitter = new Class({
* [description]
*
* @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope
* @type {?object}
* @type {?any}
* @default null
* @since 3.0.0
*/
@ -1534,7 +1547,7 @@ var ParticleEmitter = new Class({
* @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {ParticleEmitterCallback} callback - [description]
* @param {any} [context] - [description]
*
* @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter.
@ -1566,7 +1579,7 @@ var ParticleEmitter = new Class({
* @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {ParticleDeathCallback} callback - [description]
* @param {any} [context] - [description]
*
* @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter.
@ -1619,7 +1632,7 @@ var ParticleEmitter = new Class({
* @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {ParticleEmitterCallback} callback - [description]
* @param {any} thisArg - [description]
*
* @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter.
@ -1644,7 +1657,7 @@ var ParticleEmitter = new Class({
* @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {ParticleEmitterCallback} callback - [description]
* @param {any} thisArg - [description]
*
* @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter.

View file

@ -11,6 +11,17 @@ var MeasureText = require('./MeasureText');
// Key: [ Object Key, Default Value ]
/**
* A custom function that will be responsible for wrapping the text.
* @callback TextStyleWordWrapCallback
*
* @param {string} text - The string to wrap.
* @param {Phaser.GameObjects.Text} textObject - The Text instance.
*
* @return {(string|string[])} Should return the wrapped lines either as an array of lines or as a string with
* newline characters in place to indicate where breaks should happen.
*/
var propertyMap = {
fontFamily: [ 'fontFamily', 'Courier' ],
fontSize: [ 'fontSize', '16px' ],
@ -820,7 +831,7 @@ var TextStyle = new Class({
* @method Phaser.GameObjects.Components.TextStyle#setWordWrapCallback
* @since 3.0.0
*
* @param {function} callback - A custom function that will be responsible for wrapping the
* @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the
* text. It will receive two arguments: text (the string to wrap), textObject (this Text
* instance). It should return the wrapped lines either as an array of lines or as a string with
* newline characters in place to indicate where breaks should happen.

View file

@ -795,7 +795,7 @@ var Text = new Class({
* @method Phaser.GameObjects.Text#setWordWrapCallback
* @since 3.0.0
*
* @param {function} callback - A custom function that will be responsible for wrapping the
* @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the
* text. It will receive two arguments: text (the string to wrap), textObject (this Text
* instance). It should return the wrapped lines either as an array of lines or as a string with
* newline characters in place to indicate where breaks should happen.

View file

@ -237,7 +237,7 @@ var Zone = new Class({
* @since 3.0.0
*
* @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape.
* @param {function} callback - A function that will return `true` if the given x/y coords it is sent are within the shape.
* @param {HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape.
*
* @return {Phaser.GameObjects.Zone} This Game Object.
*/

View file

@ -7,6 +7,14 @@
var Centroid = require('./Centroid');
var Offset = require('./Offset');
/**
* @callback CenterFunction
*
* @param {Phaser.Geom.Triangle} triangle - [description]
*
* @return {Phaser.Math.Vector2} [description]
*/
/**
* [description]
*
@ -16,7 +24,7 @@ var Offset = require('./Offset');
* @param {Phaser.Geom.Triangle} triangle - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {function} [centerFunc] - [description]
* @param {CenterFunction} [centerFunc] - [description]
*
* @return {Phaser.Geom.Triangle} [description]
*/

View file

@ -402,7 +402,7 @@ var InputPlugin = new Class({
*
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
* @param {object} shape - [description]
* @param {function} callback - [description]
* @param {HitAreaCallback} callback - [description]
* @param {boolean} [dropZone=false] - [description]
*
* @return {Phaser.Input.InputPlugin} This Input Plugin.
@ -1053,7 +1053,7 @@ var InputPlugin = new Class({
*
* @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} gameObjects - An array of Game Objects to set the hit area on.
* @param {object} [shape] - The shape or object to check if the pointer is within for hit area checks.
* @param {function} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area.
* @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area.
*
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
*/
@ -1091,7 +1091,7 @@ var InputPlugin = new Class({
* @param {number} x - The center of the circle.
* @param {number} y - The center of the circle.
* @param {number} radius - The radius of the circle.
* @param {function} [callback] - The hit area callback. If undefined it uses Circle.Contains.
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Circle.Contains.
*
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
*/
@ -1115,7 +1115,7 @@ var InputPlugin = new Class({
* @param {number} y - The center of the ellipse.
* @param {number} width - The width of the ellipse.
* @param {number} height - The height of the ellipse.
* @param {function} [callback] - The hit area callback. If undefined it uses Ellipse.Contains.
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Ellipse.Contains.
*
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
*/
@ -1135,7 +1135,7 @@ var InputPlugin = new Class({
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} gameObjects - An array of Game Objects to set as having an ellipse hit area.
* @param {function} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
*
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
*/
@ -1189,7 +1189,7 @@ var InputPlugin = new Class({
* @param {number} y - The top-left of the rectangle.
* @param {number} width - The width of the rectangle.
* @param {number} height - The height of the rectangle.
* @param {function} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains.
*
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
*/
@ -1215,7 +1215,7 @@ var InputPlugin = new Class({
* @param {number} y2 - The y coordinate of the second point of the triangle.
* @param {number} x3 - The x coordinate of the third point of the triangle.
* @param {number} y3 - The y coordinate of the third point of the triangle.
* @param {function} [callback] - The hit area callback. If undefined it uses Triangle.Contains.
* @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Triangle.Contains.
*
* @return {Phaser.Input.InputPlugin} This InputPlugin object.
*/

View file

@ -6,6 +6,49 @@
// Phaser.Input.InteractiveObject
/**
* @callback HitAreaCallback
*
* @param {any} hitArea - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
*
* @return {boolean} [description]
*/
/**
* @typedef {object} InteractiveObject
*
* @property {Phaser.GameObjects.GameObject} gameObject - [description]
* @property {boolean} enabled - [description]
* @property {boolean} draggable - [description]
* @property {boolean} dropZone - [description]
* @property {[type]} target - [description]
* @property {Phaser.Cameras.Scene2D.Camera} camera - [description]
* @property {any} hitArea - [description]
* @property {HitAreaCallback} hitAreaCallback - [description]
* @property {number} localX - [description]
* @property {number} localY - [description]
* @property {(0|1|2)} dragState - [description]
* @property {number} dragStartX - [description]
* @property {number} dragStartY - [description]
* @property {number} dragX - [description]
* @property {number} dragY - [description]
*/
/**
* [description]
*
* @method Phaser.Input.Pointer#positionToCamera
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
* @param {any} hitArea - [description]
* @param {HitAreaCallback} hitAreaCallback - [description]
*
* @return {InteractiveObject} [description]
*/
var InteractiveObject = function (gameObject, hitArea, hitAreaCallback)
{
return {

View file

@ -9,6 +9,12 @@ var GetFastValue = require('../../../utils/object/GetFastValue');
var ProcessKeyCombo = require('./ProcessKeyCombo');
var ResetKeyCombo = require('./ResetKeyCombo');
/**
* @callback KeyboardKeydownCallback
*
* @param {KeyboardEvent} event - [description]
*/
/**
* @classdesc
* [description]
@ -219,7 +225,7 @@ var KeyCombo = new Class({
* [description]
*
* @name Phaser.Input.Keyboard.KeyCombo#onKeyDown
* @type {function}
* @type {KeyboardKeydownCallback}
* @since 3.0.0
*/
this.onKeyDown = onKeyDownHandler;

View file

@ -10,6 +10,12 @@ var Class = require('../../utils/Class');
// https://patrickhlauke.github.io/touch/tests/results/
// https://www.html5rocks.com/en/mobile/touch/
/**
* @callback TouchHandler
*
* @param {TouchEvent} event - [description]
*/
/**
* @classdesc
* [description]
@ -69,7 +75,7 @@ var TouchManager = new Class({
* [description]
*
* @name Phaser.Input.Touch.TouchManager#handler
* @type {function}
* @type {TouchHandler}
* @since 3.0.0
*/
this.handler;

View file

@ -12,6 +12,12 @@ var MergeXHRSettings = require('./MergeXHRSettings');
var XHRLoader = require('./XHRLoader');
var XHRSettings = require('./XHRSettings');
/**
* @callback FileProcessCallback
*
* @param {Phaser.Loader.File} file - [description]
*/
/**
* @classdesc
* [description]
@ -350,7 +356,7 @@ var File = new Class({
* @method Phaser.Loader.File#onProcess
* @since 3.0.0
*
* @param {function} callback - The callback to invoke to process this File.
* @param {FileProcessCallback} callback - The callback to invoke to process this File.
*/
onProcess: function (callback)
{

View file

@ -62,7 +62,7 @@ var AudioFile = new Class({
* @method Phaser.Loader.FileTypes.AudioFile#onProcess
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {FileProcessCallback} callback - [description]
*/
onProcess: function (callback)
{

View file

@ -144,8 +144,8 @@ var ArcadePhysics = new Class({
*
* @param {Phaser.GameObjects.GameObject|array} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body.
* @param {Phaser.GameObjects.GameObject|array} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body.
* @param {function} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter.
* @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`.
* @param {ArcadePhysicsCallback} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter.
* @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`.
* @param {object} [callbackContext] - The context in which to run the callbacks.
*
* @return {boolean} True if an overlap occurred otherwise false.
@ -167,8 +167,8 @@ var ArcadePhysics = new Class({
*
* @param {Phaser.GameObjects.GameObject|array} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body.
* @param {Phaser.GameObjects.GameObject|array} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body.
* @param {function} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter.
* @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {ArcadePhysicsCallback} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter.
* @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`.
* @param {object} [callbackContext] - The context in which to run the callbacks.
*
* @return {boolean} True if a collision occurred otherwise false.

View file

@ -19,8 +19,8 @@ var Class = require('../../utils/Class');
* @param {boolean} overlapOnly - [description]
* @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision.
* @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision.
* @param {function} collideCallback - The callback to invoke when the two objects collide.
* @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean.
* @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide.
* @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean.
* @param {object} callbackContext - The scope in which to call the callbacks.
*/
var Collider = new Class({
@ -88,7 +88,7 @@ var Collider = new Class({
* [description]
*
* @name Phaser.Physics.Arcade.Collider#collideCallback
* @type {function}
* @type {ArcadePhysicsCallback}
* @since 3.0.0
*/
this.collideCallback = collideCallback;
@ -97,7 +97,7 @@ var Collider = new Class({
* [description]
*
* @name Phaser.Physics.Arcade.Collider#processCallback
* @type {function}
* @type {ArcadePhysicsCallback}
* @since 3.0.0
*/
this.processCallback = processCallback;

View file

@ -65,8 +65,8 @@ var Factory = new Class({
*
* @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision.
* @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision.
* @param {function} collideCallback - The callback to invoke when the two objects collide.
* @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean.
* @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide.
* @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean.
* @param {object} callbackContext - The scope in which to call the callbacks.
*
* @return {Phaser.Physics.Arcade.Collider} The Collider that was created.
@ -84,8 +84,8 @@ var Factory = new Class({
*
* @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap.
* @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap.
* @param {function} collideCallback - The callback to invoke when the two objects collide.
* @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean.
* @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide.
* @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean.
* @param {object} callbackContext - The scope in which to call the callbacks.
*
* @return {Phaser.Physics.Arcade.Collider} The Collider that was created.

View file

@ -565,9 +565,9 @@ var World = new Class({
*
* @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision.
* @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision.
* @param {function} collideCallback - The callback to invoke when the two objects collide.
* @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean.
* @param {object} callbackContext - The scope in which to call the callbacks.
* @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide.
* @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean.
* @param {object} [callbackContext] - The scope in which to call the callbacks.
*
* @return {Phaser.Physics.Arcade.Collider} The Collider that was created.
*/
@ -592,9 +592,9 @@ var World = new Class({
*
* @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap.
* @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap.
* @param {function} collideCallback - The callback to invoke when the two objects overlap.
* @param {function} processCallback - The callback to invoke when the two objects overlap. Must return a boolean.
* @param {object} callbackContext - The scope in which to call the callbacks.
* @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects overlap.
* @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects overlap. Must return a boolean.
* @param {object} [callbackContext] - The scope in which to call the callbacks.
*
* @return {Phaser.Physics.Arcade.Collider} The Collider that was created.
*/
@ -865,7 +865,7 @@ var World = new Class({
*
* @param {Phaser.Physics.Arcade.Body} body1 - [description]
* @param {Phaser.Physics.Arcade.Body} body2 - [description]
* @param {function} processCallback - [description]
* @param {ArcadePhysicsCallback} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {boolean} overlapOnly - [description]
*
@ -1249,9 +1249,9 @@ var World = new Class({
*
* @param {Phaser.GameObjects.GameObject} object1 - [description]
* @param {Phaser.GameObjects.GameObject} object2 - [description]
* @param {function} overlapCallback - [description]
* @param {function} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {ArcadePhysicsCallback} [overlapCallback] - [description]
* @param {ArcadePhysicsCallback} [processCallback] - [description]
* @param {object} [callbackContext] - [description]
*
* @return {boolean} [description]
*/
@ -1272,9 +1272,9 @@ var World = new Class({
*
* @param {Phaser.GameObjects.GameObject} object1 - [description]
* @param {Phaser.GameObjects.GameObject} object2 - [description]
* @param {function} collideCallback - [description]
* @param {function} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {ArcadePhysicsCallback} [collideCallback] - [description]
* @param {ArcadePhysicsCallback} [processCallback] - [description]
* @param {object} [callbackContext] - [description]
*
* @return {boolean} [description]
*/
@ -1295,8 +1295,8 @@ var World = new Class({
*
* @param {Phaser.GameObjects.GameObject} object1 - [description]
* @param {Phaser.GameObjects.GameObject} object2 - [description]
* @param {function} collideCallback - [description]
* @param {function} processCallback - [description]
* @param {ArcadePhysicsCallback} collideCallback - [description]
* @param {ArcadePhysicsCallback} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {boolean} overlapOnly - [description]
*
@ -1356,8 +1356,8 @@ var World = new Class({
*
* @param {Phaser.GameObjects.GameObject} object1 - [description]
* @param {Phaser.GameObjects.GameObject} object2 - [description]
* @param {function} collideCallback - [description]
* @param {function} processCallback - [description]
* @param {ArcadePhysicsCallback} collideCallback - [description]
* @param {ArcadePhysicsCallback} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {boolean} overlapOnly - [description]
*
@ -1434,8 +1434,8 @@ var World = new Class({
*
* @param {Phaser.GameObjects.GameObject} sprite1 - [description]
* @param {Phaser.GameObjects.GameObject} sprite2 - [description]
* @param {function} collideCallback - [description]
* @param {function} processCallback - [description]
* @param {ArcadePhysicsCallback} collideCallback - [description]
* @param {ArcadePhysicsCallback} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {boolean} overlapOnly - [description]
*
@ -1469,8 +1469,8 @@ var World = new Class({
*
* @param {Phaser.GameObjects.GameObject} sprite - [description]
* @param {Phaser.GameObjects.Group} group - [description]
* @param {function} collideCallback - [description]
* @param {function} processCallback - [description]
* @param {ArcadePhysicsCallback} collideCallback - [description]
* @param {ArcadePhysicsCallback} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {boolean} overlapOnly - [description]
*
@ -1532,8 +1532,8 @@ var World = new Class({
*
* @param {Phaser.GameObjects.Group} group - [description]
* @param {Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} tilemapLayer - [description]
* @param {function} collideCallback - [description]
* @param {function} processCallback - [description]
* @param {ArcadePhysicsCallback} collideCallback - [description]
* @param {ArcadePhysicsCallback} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {boolean} overlapOnly - [description]
*
@ -1572,8 +1572,8 @@ var World = new Class({
*
* @param {Phaser.GameObjects.GameObject} sprite - [description]
* @param {Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} tilemapLayer - [description]
* @param {function} collideCallback - [description]
* @param {function} processCallback - [description]
* @param {ArcadePhysicsCallback} collideCallback - [description]
* @param {ArcadePhysicsCallback} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {boolean} overlapOnly - [description]
*
@ -1671,8 +1671,8 @@ var World = new Class({
*
* @param {Phaser.GameObjects.Group} group1 - [description]
* @param {Phaser.GameObjects.Group} group2 - [description]
* @param {function} collideCallback - [description]
* @param {function} processCallback - [description]
* @param {ArcadePhysicsCallback} collideCallback - [description]
* @param {ArcadePhysicsCallback} processCallback - [description]
* @param {object} callbackContext - [description]
* @param {boolean} overlapOnly - [description]
*

View file

@ -7,6 +7,13 @@
var CONST = require('./const');
var Extend = require('../../utils/object/Extend');
/**
* @callback ArcadePhysicsCallback
*
* @param {Phaser.GameObjects.GameObject} object1 - [description]
* @param {Phaser.GameObjects.GameObject} object2 - [description]
*/
/**
* @namespace Phaser.Physics.Arcade
*/

View file

@ -10,6 +10,12 @@ var GetVelocity = require('./GetVelocity');
var TYPE = require('./TYPE');
var UpdateMotion = require('./UpdateMotion');
/**
* @callback BodyUpdateCallback
*
* @param {Phaser.Physics.Impact.Body} body - [description]
*/
/**
* @classdesc
* An Impact.js compatible physics body.
@ -289,7 +295,7 @@ var Body = new Class({
* [description]
*
* @name Phaser.Physics.Impact.Body#updateCallback
* @type {function}
* @type {?BodyUpdateCallback}
* @since 3.0.0
*/
this.updateCallback;

View file

@ -6,6 +6,14 @@
var COLLIDES = require('../COLLIDES');
/**
* @callback CollideCallback
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {Phaser.Physics.Impact.Body} other - [description]
* @param {string} axis - [description]
*/
/**
* [description]
*
@ -23,7 +31,7 @@ var Collides = {
* @method Phaser.Physics.Impact.Components.Collides#setCollideCallback
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {CollideCallback} callback - [description]
* @param {object} scope - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.

View file

@ -132,7 +132,7 @@ var CanvasRenderer = new Class({
* Map to the required function.
*
* @name Phaser.Renderer.Canvas.CanvasRenderer#drawImage
* @type {function}
* @type {Phaser.Renderer.Canvas.DrawImage}
* @since 3.0.0
*/
this.drawImage = DrawImage(this.config.roundPixels);
@ -141,7 +141,7 @@ var CanvasRenderer = new Class({
* [description]
*
* @name Phaser.Renderer.Canvas.CanvasRenderer#blitImage
* @type {function}
* @type {Phaser.Renderer.Canvas.BlitImage}
* @since 3.0.0
*/
this.blitImage = BlitImage(this.config.roundPixels);
@ -189,7 +189,7 @@ var CanvasRenderer = new Class({
* [description]
*
* @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback
* @type {?function}
* @type {?SnapshotCallback}
* @default null
* @since 3.0.0
*/
@ -494,7 +494,7 @@ var CanvasRenderer = new Class({
* @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {SnapshotCallback} callback - [description]
* @param {string} type - [description]
* @param {number} encoderOptions - [description]
*/

View file

@ -4,6 +4,12 @@
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @callback SnapshotCallback
*
* @param {HTMLImageElement} snapshot - [description]
*/
/**
* @namespace Phaser.Renderer.Snapshot
*/

View file

@ -16,6 +16,12 @@ var FlatTintPipeline = require('./pipelines/FlatTintPipeline');
var ForwardDiffuseLightPipeline = require('./pipelines/ForwardDiffuseLightPipeline');
var TextureTintPipeline = require('./pipelines/TextureTintPipeline');
/**
* @callback WebGLContextCallback
*
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description]
*/
/**
* @classdesc
* [description]
@ -115,7 +121,7 @@ var WebGLRenderer = new Class({
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks
* @type {function[]}
* @type {WebGLContextCallback[]}
* @since 3.0.0
*/
this.lostContextCallbacks = [];
@ -124,7 +130,7 @@ var WebGLRenderer = new Class({
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks
* @type {function[]}
* @type {WebGLContextCallback[]}
* @since 3.0.0
*/
this.restoredContextCallbacks = [];
@ -484,7 +490,7 @@ var WebGLRenderer = new Class({
* @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {WebGLContextCallback} callback - [description]
* @param {object} target - [description]
*
* @return {Phaser.Renderer.WebGL.WebGLRenderer} [description]
@ -502,7 +508,7 @@ var WebGLRenderer = new Class({
* @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {WebGLContextCallback} callback - [description]
* @param {object} target - [description]
*
* @return {Phaser.Renderer.WebGL.WebGLRenderer} [description]
@ -1533,7 +1539,7 @@ var WebGLRenderer = new Class({
* @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {SnapshotCallback} callback - [description]
* @param {string} type - [description]
* @param {float} encoderOptions - [description]
*

View file

@ -7,6 +7,15 @@ var Class = require('../utils/Class');
var EventEmitter = require('eventemitter3');
var NOOP = require('../utils/NOOP');
/**
* @callback EachActiveSoundCallback
*
* @param {Phaser.Sound.BaseSoundManager} manager - [description]
* @param {Phaser.Sound.BaseSound} sound - [description]
* @param {number} index - [description]
* @param {Phaser.Sound.BaseSound[]} sounds - [description]
*/
/**
* @classdesc
* 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({
* @private
* @since 3.0.0
*
* @param {function} callbackfn - Callback function. (sound: ISound, index: number, array: ISound[]) => void
* @param {EachActiveSoundCallback} callback - Callback function. (sound: ISound, index: number, array: ISound[]) => void
* @param {object} [scope] - Callback context.
*/
forEachActiveSound: function (callbackfn, scope)
forEachActiveSound: function (callback, scope)
{
var _this = this;
this.sounds.forEach(function (sound, index)
{
if (!sound.pendingRemove)
{
callbackfn.call(scope || _this, sound, index, _this.sounds);
callback.call(scope || _this, sound, index, _this.sounds);
}
});
},

View file

@ -6,6 +6,13 @@
var Class = require('../utils/Class');
/**
* @callback EachListCallback
*
* @param {any} item - [description]
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child.
*/
/**
* @classdesc
* [description]
@ -737,7 +744,7 @@ var List = new Class({
* @method Phaser.Structs.List#each
* @since 3.0.0
*
* @param {function} callback - The function to call.
* @param {EachListCallback} callback - The function to call.
* @param {object} [thisArg] - Value to use as `this` when executing callback.
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child.
*/

View file

@ -6,6 +6,15 @@
var Class = require('../utils/Class');
/**
* @callback EachMapCallback
*
* @param {string} key - [description]
* @param {any} entry - [description]
*
* @return {?boolean} [description]
*/
/**
* @classdesc
* The keys of a Map can be arbitrary values.
@ -32,7 +41,7 @@ var Map = new Class({
* [description]
*
* @name Phaser.Structs.Map#entries
* @type {object}
* @type {Object.<string, any>}
* @default {}
* @since 3.0.0
*/
@ -237,7 +246,7 @@ var Map = new Class({
* @method Phaser.Structs.Map#each
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {EachMapCallback} callback - [description]
*
* @return {Phaser.Structs.Map} This Map object.
*/

View file

@ -6,6 +6,15 @@
var Class = require('../utils/Class');
/**
* @callback EachSetCallback
*
* @param {any} entry - [description]
* @param {number} index - [description]
*
* @return {?boolean} [description]
*/
/**
* @classdesc
* A Set is a collection of unique elements.
@ -148,7 +157,7 @@ var Set = new Class({
* @method Phaser.Structs.Set#each
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {EachSetCallback} callback - [description]
* @param {object} callbackScope - [description]
*
* @return {Phaser.Structs.Set} This Set object.
@ -189,7 +198,7 @@ var Set = new Class({
* @method Phaser.Structs.Set#iterate
* @since 3.0.0
*
* @param {function} callback - [description]
* @param {EachSetCallback} callback - [description]
* @param {object} callbackScope - [description]
*
* @return {Phaser.Structs.Set} This Set object.

View file

@ -13,6 +13,13 @@ var GetValue = require('../utils/object/GetValue');
var Parser = require('./parsers');
var Texture = require('./Texture');
/**
* @callback EachTextureCallback
*
* @param {Phaser.Textures.Texture} texture - [description]
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child.
*/
/**
* @classdesc
* Textures are managed by the global TextureManager. This is a singleton class that is
@ -738,7 +745,7 @@ var TextureManager = new Class({
* @method Phaser.Textures.TextureManager#each
* @since 3.0.0
*
* @param {function} callback - The callback function to be sent the Textures.
* @param {EachTextureCallback} callback - The callback function to be sent the Textures.
* @param {object} scope - The value to use as `this` when executing the callback.
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child.
*/