mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Add callbacks on GameObjects
This commit is contained in:
parent
41d7c4b715
commit
b4a30b8e43
10 changed files with 100 additions and 39 deletions
|
@ -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.
|
||||
|
|
|
@ -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]
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
|
@ -44,7 +51,7 @@ var List = require('../../structs/List');
|
|||
* @extends Phaser.GameObjects.Components.Texture
|
||||
* @extends Phaser.GameObjects.Components.Transform
|
||||
* @extends Phaser.GameObjects.Components.Visible
|
||||
*
|
||||
*
|
||||
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time.
|
||||
* @param {number} [x=0] - The x coordinate of this Game Object in world space.
|
||||
* @param {number} [y=0] - The y coordinate of this Game Object in world space.
|
||||
|
@ -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]
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -105,7 +105,7 @@ var Zone = new Class({
|
|||
/**
|
||||
* The displayed width of this Game Object.
|
||||
* This value takes into account the scale factor.
|
||||
*
|
||||
*
|
||||
* @name Phaser.GameObjects.Zone#displayWidth
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
|
@ -127,7 +127,7 @@ var Zone = new Class({
|
|||
/**
|
||||
* The displayed height of this Game Object.
|
||||
* This value takes into account the scale factor.
|
||||
*
|
||||
*
|
||||
* @name Phaser.GameObjects.Zone#displayHeight
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue