Matter and Snapshot typedefs

This commit is contained in:
Richard Davey 2019-02-13 15:22:29 +00:00
parent b4dbfea0a1
commit 42cb39749f
16 changed files with 96 additions and 69 deletions

View file

@ -12,14 +12,6 @@ var GetFastValue = require('../../utils/object/GetFastValue');
var HasValue = require('../../utils/object/HasValue');
var Vertices = require('./lib/geometry/Vertices');
/**
* @typedef {object} MatterTileOptions
*
* @property {MatterJS.Body} [body=null] - An existing Matter body to be used instead of creating a new one.
* @property {boolean} [isStatic=true] - Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved.
* @property {boolean} [addToWorld=true] - Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world.
*/
/**
* @classdesc
* A wrapper around a Tile that provides access to a corresponding Matter body. A tile can only
@ -49,7 +41,7 @@ var Vertices = require('./lib/geometry/Vertices');
*
* @param {Phaser.Physics.Matter.World} world - [description]
* @param {Phaser.Tilemaps.Tile} tile - The target tile that should have a Matter body.
* @param {MatterTileOptions} [options] - Options to be used when creating the Matter body.
* @param {Phaser.Physics.Matter.Types.MatterTileOptions} [options] - Options to be used when creating the Matter body.
*/
var MatterTileBody = new Class({
@ -121,20 +113,13 @@ var MatterTileBody = new Class({
}
},
/**
* @typedef {object} MatterBodyTileOptions
*
* @property {boolean} [isStatic=true] - Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved.
* @property {boolean} [addToWorld=true] - Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world.
*/
/**
* Sets the current body to a rectangle that matches the bounds of the tile.
*
* @method Phaser.Physics.Matter.TileBody#setFromTileRectangle
* @since 3.0.0
*
* @param {MatterBodyTileOptions} [options] - Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts.
* @param {Phaser.Physics.Matter.Types.MatterBodyTileOptions} [options] - Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts.
*
* @return {Phaser.Physics.Matter.TileBody} This TileBody object.
*/

View file

@ -0,0 +1,7 @@
/**
* @typedef {object} Phaser.Physics.Matter.Types.MatterBodyTileOptions
* @since 3.0.0
*
* @property {boolean} [isStatic=true] - Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved.
* @property {boolean} [addToWorld=true] - Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world.
*/

View file

@ -0,0 +1,8 @@
/**
* @typedef {object} Phaser.Physics.Matter.Types.MatterTileOptions
* @since 3.0.0
*
* @property {MatterJS.Body} [body=null] - An existing Matter body to be used instead of creating a new one.
* @property {boolean} [isStatic=true] - Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved.
* @property {boolean} [addToWorld=true] - Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world.
*/

View file

@ -0,0 +1,9 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @namespace Phaser.Physics.Matter.Types
*/

View file

@ -12,22 +12,6 @@ var corePlugins = {};
// These are the source objects, not instantiated.
var customPlugins = {};
/**
* @typedef {object} CorePluginContainer
*
* @property {string} key - The unique name of this plugin in the core plugin cache.
* @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated.
* @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used.
* @property {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin?
*/
/**
* @typedef {object} CustomPluginContainer
*
* @property {string} key - The unique name of this plugin in the custom plugin cache.
* @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated.
*/
var PluginCache = {};
/**
@ -110,7 +94,7 @@ PluginCache.hasCustom = function (key)
*
* @param {string} key - The key of the core plugin to get.
*
* @return {CorePluginContainer} The core plugin object.
* @return {Phaser.Plugins.Types.CorePluginContainer} The core plugin object.
*/
PluginCache.getCore = function (key)
{
@ -125,7 +109,7 @@ PluginCache.getCore = function (key)
*
* @param {string} key - The key of the custom plugin to get.
*
* @return {CustomPluginContainer} The custom plugin object.
* @return {Phaser.Plugins.Types.CustomPluginContainer} The custom plugin object.
*/
PluginCache.getCustom = function (key)
{

View file

@ -14,15 +14,6 @@ var GetFastValue = require('../utils/object/GetFastValue');
var PluginCache = require('./PluginCache');
var Remove = require('../utils/array/Remove');
/**
* @typedef {object} GlobalPlugin
*
* @property {string} key - The unique name of this plugin within the plugin cache.
* @property {function} plugin - An instance of the plugin.
* @property {boolean} [active] - Is the plugin active or not?
* @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used.
*/
/**
* @classdesc
* The PluginManager is responsible for installing and adding plugins to Phaser.
@ -88,7 +79,7 @@ var PluginManager = new Class({
* A plugin must have been started at least once in order to appear in this list.
*
* @name Phaser.Plugins.PluginManager#plugins
* @type {GlobalPlugin[]}
* @type {Phaser.Plugins.Types.GlobalPlugin[]}
* @since 3.8.0
*/
this.plugins = [];
@ -231,7 +222,7 @@ var PluginManager = new Class({
for (i = 0; i < globalPlugins.length; i++)
{
pluginKey = globalPlugins[i];
if (game[pluginKey])
{
sys[pluginKey] = game[pluginKey];
@ -291,7 +282,7 @@ var PluginManager = new Class({
for (i = 0; i < pluginList.length; i++)
{
var entry = pluginList[i];
if (entry.mapping)
{
scene[entry.mapping] = entry.plugin;
@ -488,7 +479,7 @@ var PluginManager = new Class({
*
* @param {string} key - The unique plugin key.
*
* @return {GlobalPlugin} The plugin entry.
* @return {Phaser.Plugins.Types.GlobalPlugin} The plugin entry.
*/
getEntry: function (key)
{

View file

@ -0,0 +1,9 @@
/**
* @typedef {object} Phaser.Plugins.Types.CorePluginContainer
* @since 3.8.0
*
* @property {string} key - The unique name of this plugin in the core plugin cache.
* @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated.
* @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used.
* @property {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin?
*/

View file

@ -0,0 +1,7 @@
/**
* @typedef {object} Phaser.Plugins.Types.CustomPluginContainer
* @since 3.8.0
*
* @property {string} key - The unique name of this plugin in the custom plugin cache.
* @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated.
*/

View file

@ -0,0 +1,9 @@
/**
* @typedef {object} Phaser.Plugins.Types.GlobalPlugin
* @since 3.0.0
*
* @property {string} key - The unique name of this plugin within the plugin cache.
* @property {function} plugin - An instance of the plugin.
* @property {boolean} [active] - Is the plugin active or not?
* @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used.
*/

View file

@ -0,0 +1,9 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @namespace Phaser.Plugins.Types
*/

View file

@ -158,7 +158,7 @@ var CanvasRenderer = new Class({
* If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered.
*
* @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotState
* @type {SnapshotState}
* @type {Phaser.Renderer.Snapshot.Types.SnapshotState}
* @since 3.16.0
*/
this.snapshotState = {

View file

@ -4,25 +4,6 @@
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @callback SnapshotCallback
*
* @param {(Phaser.Display.Color|HTMLImageElement)} snapshot - Either a Color object if a single pixel is being grabbed, or a new Image which contains a snapshot of the canvas contents.
*/
/**
* @typedef {object} SnapshotState
*
* @property {SnapshotCallback} callback - The function to call after the snapshot is taken.
* @property {string} [type='image/png'] - The format of the image to create, usually `image/png` or `image/jpeg`.
* @property {number} [encoderOptions=0.92] - The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`.
* @property {integer} [x=0] - The x coordinate to start the snapshot from.
* @property {integer} [y=0] - The y coordinate to start the snapshot from.
* @property {integer} [width] - The width of the snapshot.
* @property {integer} [height] - The height of the snapshot.
* @property {boolean} [getPixel=false] - Is this a snapshot to get a single pixel, or an area?
*/
/**
* @namespace Phaser.Renderer.Snapshot
*/

View file

@ -0,0 +1,6 @@
/**
* @callback Phaser.Renderer.Snapshot.Types.SnapshotCallback
* @since 3.16.1
*
* @param {(Phaser.Display.Color|HTMLImageElement)} snapshot - Either a Color object if a single pixel is being grabbed, or a new Image which contains a snapshot of the canvas contents.
*/

View file

@ -0,0 +1,13 @@
/**
* @typedef {object} Phaser.Renderer.Snapshot.Types.SnapshotState
* @since 3.16.1
*
* @property {Phaser.Renderer.Snapshot.Types.SnapshotCallback} callback - The function to call after the snapshot is taken.
* @property {string} [type='image/png'] - The format of the image to create, usually `image/png` or `image/jpeg`.
* @property {number} [encoderOptions=0.92] - The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`.
* @property {integer} [x=0] - The x coordinate to start the snapshot from.
* @property {integer} [y=0] - The y coordinate to start the snapshot from.
* @property {integer} [width] - The width of the snapshot.
* @property {integer} [height] - The height of the snapshot.
* @property {boolean} [getPixel=false] - Is this a snapshot to get a single pixel, or an area?
*/

View file

@ -0,0 +1,9 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @namespace Phaser.Renderer.Snapshot.Types
*/

View file

@ -198,7 +198,7 @@ var WebGLRenderer = new Class({
* If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered.
*
* @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState
* @type {SnapshotState}
* @type {Phaser.Renderer.Snapshot.Types.SnapshotState}
* @since 3.0.0
*/
this.snapshotState = {