mirror of
https://github.com/photonstorm/phaser
synced 2024-11-25 14:10:42 +00:00
Added jsdocs
This commit is contained in:
parent
ef87b33a10
commit
14c5aad929
3 changed files with 288 additions and 22 deletions
|
@ -6,21 +6,42 @@
|
|||
|
||||
var Class = require('../utils/Class');
|
||||
|
||||
// Phaser.Data.DataManager
|
||||
|
||||
/**
|
||||
* The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin.
|
||||
* You can then search, query it, and retrieve the data. The parent must either extend EventEmitter,
|
||||
* or have a property called `events` that is an instance of it.
|
||||
*/
|
||||
* @classdesc
|
||||
* The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin.
|
||||
* You can then search, query it, and retrieve the data. The parent must either extend EventEmitter,
|
||||
* or have a property called `events` that is an instance of it.
|
||||
*
|
||||
* @class DataManager
|
||||
* @memberOf Phaser.Data
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {any} parent - [description]
|
||||
* @param {any} eventEmitter - [description]
|
||||
*/
|
||||
var DataManager = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
function DataManager (parent, eventEmitter)
|
||||
{
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Data.DataManager#parent
|
||||
* @type {any}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.parent = parent;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Data.DataManager#events
|
||||
* @type {Phaser.Events.EventEmitter}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.events = eventEmitter;
|
||||
|
||||
if (!eventEmitter)
|
||||
|
@ -28,21 +49,63 @@ var DataManager = new Class({
|
|||
this.events = (parent.events) ? parent.events : parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Data.DataManager#list
|
||||
* @type {object}
|
||||
* @default {}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.list = {};
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Data.DataManager#blockSet
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.blockSet = false;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Data.DataManager#_frozen
|
||||
* @type {boolean}
|
||||
* @private
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._frozen = false;
|
||||
|
||||
this.events.once('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
// Retrieves the value for the given key, or undefined if it doesn't exist.
|
||||
/**
|
||||
* Retrieves the value for the given key, or undefined if it doesn't exist.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#get
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
*
|
||||
* @return {any} [description]
|
||||
*/
|
||||
get: function (key)
|
||||
{
|
||||
return this.list[key];
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManager#getAll
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {object} [description]
|
||||
*/
|
||||
getAll: function ()
|
||||
{
|
||||
var results = {};
|
||||
|
@ -55,6 +118,16 @@ var DataManager = new Class({
|
|||
return results;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManager#query
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} search - [description]
|
||||
*
|
||||
* @return {object} [description]
|
||||
*/
|
||||
query: function (search)
|
||||
{
|
||||
var results = {};
|
||||
|
@ -70,6 +143,17 @@ var DataManager = new Class({
|
|||
return results;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManager#set
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {any} data - [description]
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
set: function (key, data)
|
||||
{
|
||||
if (this._frozen)
|
||||
|
@ -107,13 +191,17 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Passes all data entries to the given callback. Stores the result of the callback.
|
||||
*
|
||||
* @method each
|
||||
* @param {function} 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.
|
||||
*/
|
||||
* Passes all data entries to the given callback. Stores the result of the callback.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#each
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {function} 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.
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
each: function (callback, scope)
|
||||
{
|
||||
var args = [ this.parent, null, undefined ];
|
||||
|
@ -134,6 +222,17 @@ var DataManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManager#merge
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} data - [description]
|
||||
* @param {boolean} overwrite - [description]
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
merge: function (data, overwrite)
|
||||
{
|
||||
if (overwrite === undefined) { overwrite = true; }
|
||||
|
@ -150,6 +249,16 @@ var DataManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManager#remove
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
remove: function (key)
|
||||
{
|
||||
if (!this._frozen && this.has(key))
|
||||
|
@ -164,7 +273,16 @@ var DataManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Gets the data associated with the given 'key', deletes it from this Data store, then returns it.
|
||||
/**
|
||||
* Gets the data associated with the given 'key', deletes it from this Data store, then returns it.
|
||||
*
|
||||
* @method Phaser.Data.DataManager#pop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
*
|
||||
* @return {any} [description]
|
||||
*/
|
||||
pop: function (key)
|
||||
{
|
||||
var data = undefined;
|
||||
|
@ -181,11 +299,31 @@ var DataManager = new Class({
|
|||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManager#has
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
has: function (key)
|
||||
{
|
||||
return this.list.hasOwnProperty(key);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManager#setFreeze
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} value - [description]
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
setFreeze: function (value)
|
||||
{
|
||||
this._frozen = value;
|
||||
|
@ -193,6 +331,14 @@ var DataManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManager#reset
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Data.DataManager} This DataManager object.
|
||||
*/
|
||||
reset: function ()
|
||||
{
|
||||
for (var key in this.list)
|
||||
|
@ -202,8 +348,16 @@ var DataManager = new Class({
|
|||
|
||||
this.blockSet = false;
|
||||
this._frozen = false;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManager#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.reset();
|
||||
|
@ -216,11 +370,12 @@ var DataManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Freeze this Data component, so no changes can be written to it.
|
||||
*
|
||||
* @name freeze
|
||||
* @property {boolean} freeze
|
||||
*/
|
||||
* Freeze this Data component, so no changes can be written to it.
|
||||
*
|
||||
* @name Phaser.Data.DataManager#freeze
|
||||
* @type {boolean}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
freeze: {
|
||||
|
||||
get: function ()
|
||||
|
@ -235,6 +390,13 @@ var DataManager = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the total number of entries in this Data component.
|
||||
*
|
||||
* @name Phaser.Data.DataManager#count
|
||||
* @type {integer}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
count: {
|
||||
|
||||
get: function ()
|
||||
|
|
|
@ -8,6 +8,20 @@ var Class = require('../utils/Class');
|
|||
var DataManager = require('./DataManager');
|
||||
var PluginManager = require('../plugins/PluginManager');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin.
|
||||
* You can then search, query it, and retrieve the data. The parent must either extend EventEmitter,
|
||||
* or have a property called `events` that is an instance of it.
|
||||
*
|
||||
* @class DataManagerPlugin
|
||||
* @extends Phaser.Data.DataManager
|
||||
* @memberOf Phaser.Data
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
*/
|
||||
var DataManagerPlugin = new Class({
|
||||
|
||||
Extends: DataManager,
|
||||
|
@ -16,9 +30,22 @@ var DataManagerPlugin = new Class({
|
|||
|
||||
function DataManagerPlugin (scene)
|
||||
{
|
||||
// The Scene that owns this plugin
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Data.DataManagerPlugin#scene
|
||||
* @type {Phaser.Scene}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Data.DataManagerPlugin#systems
|
||||
* @type {Phaser.Scenes.Systems}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
|
@ -29,6 +56,12 @@ var DataManagerPlugin = new Class({
|
|||
DataManager.call(this, this.scene, scene.sys.events);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManagerPlugin#boot
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
@ -37,11 +70,23 @@ var DataManagerPlugin = new Class({
|
|||
eventEmitter.on('destroy', this.destroyPlugin, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManagerPlugin#shutdownPlugin
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdownPlugin: function ()
|
||||
{
|
||||
// Should we reset the events?
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Data.DataManagerPlugin#destroyPlugin
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroyPlugin: function ()
|
||||
{
|
||||
this.destroy();
|
||||
|
|
|
@ -4,8 +4,25 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace Phaser.Renderer.WebGL.Utils
|
||||
* @since 3.0.0
|
||||
*/
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Renderer.WebGL.Utils.getTintFromFloats
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} r - [description]
|
||||
* @param {number} g - [description]
|
||||
* @param {number} b - [description]
|
||||
* @param {number} a - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
getTintFromFloats: function (r, g, b, a)
|
||||
{
|
||||
var ur = ((r * 255.0)|0) & 0xFF;
|
||||
|
@ -16,12 +33,34 @@ module.exports = {
|
|||
return ((ua << 24) | (ur << 16) | (ug << 8) | ub) >>> 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} rgb - [description]
|
||||
* @param {number} a - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
getTintAppendFloatAlpha: function (rgb, a)
|
||||
{
|
||||
var ua = ((a * 255.0)|0) & 0xFF;
|
||||
return ((ua << 24) | rgb) >>> 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlphaAndSwap
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} rgb - [description]
|
||||
* @param {number} a - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
getTintAppendFloatAlphaAndSwap: function (rgb, a)
|
||||
{
|
||||
var ur = ((rgb >> 16)|0) & 0xff;
|
||||
|
@ -32,6 +71,16 @@ module.exports = {
|
|||
return ((ua << 24) | (ub << 16) | (ug << 8) | ur) >>> 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Renderer.WebGL.Utils.getFloatsFromUintRGB
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} rgb - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
getFloatsFromUintRGB: function (rgb)
|
||||
{
|
||||
var ur = ((rgb >> 16)|0) & 0xff;
|
||||
|
@ -41,6 +90,16 @@ module.exports = {
|
|||
return [ ur / 255.0, ug / 255.0, ub / 255.0 ];
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Renderer.WebGL.Utils.getComponentCount
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} attributes - [description]
|
||||
*
|
||||
* @return {number} [description]
|
||||
*/
|
||||
getComponentCount: function (attributes)
|
||||
{
|
||||
var count = 0;
|
||||
|
@ -62,4 +121,4 @@ module.exports = {
|
|||
return count;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue