Updated jsdocs.

This commit is contained in:
Richard Davey 2018-02-09 16:52:08 +00:00
parent 2434bb187a
commit d3cb0761d2
3 changed files with 140 additions and 162 deletions

View file

@ -505,7 +505,7 @@ var Body = new Class({
* [description]
*
* @method Phaser.Physics.Impact.Body#fromJSON
* @todo
* @todo Code it!
* @since 3.0.0
*
* @param {object} config - [description]

View file

@ -112,6 +112,32 @@ var ImpactPhysics = new Class({
eventEmitter.on('destroy', this.destroy, this);
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#pause
* @since 3.0.0
*
* @return {[type]} [description]
*/
pause: function ()
{
return this.world.pause();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#resume
* @since 3.0.0
*
* @return {[type]} [description]
*/
resume: function ()
{
return this.world.resume();
},
/**
* [description]
*

View file

@ -33,7 +33,6 @@ var World = new Class({
{
EventEmitter.call(this);
/**
* [description]
*
@ -43,69 +42,64 @@ var World = new Class({
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#bodies
* @type {[type]}
* @type {Phaser.Structs.Set}
* @since 3.0.0
*/
this.bodies = new Set();
/**
* [description]
*
* @name Phaser.Physics.Impact.World#gravity
* @type {[type]}
* @type {number}
* @default 0
* @since 3.0.0
*/
this.gravity = GetFastValue(config, 'gravity', 0);
// Spatial hash cell dimensions
/**
* [description]
* Spatial hash cell dimensions
*
* @name Phaser.Physics.Impact.World#cellSize
* @type {[type]}
* @type {integer}
* @default 64
* @since 3.0.0
*/
this.cellSize = GetFastValue(config, 'cellSize', 64);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#collisionMap
* @type {[type]}
* @type {Phaser.Physics.Impact.CollisionMap}
* @since 3.0.0
*/
this.collisionMap = new CollisionMap();
/**
* [description]
*
* @name Phaser.Physics.Impact.World#timeScale
* @type {[type]}
* @type {float}
* @default 1
* @since 3.0.0
*/
this.timeScale = GetFastValue(config, 'timeScale', 1);
// Impacts maximum time step is 20 fps.
/**
* [description]
* Impacts maximum time step is 20 fps.
*
* @name Phaser.Physics.Impact.World#maxStep
* @type {[type]}
* @type {number}
* @default 0.05
* @since 3.0.0
*/
this.maxStep = GetFastValue(config, 'maxStep', 0.05);
/**
* [description]
*
@ -116,34 +110,31 @@ var World = new Class({
*/
this.enabled = true;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#drawDebug
* @type {[type]}
* @type {boolean}
* @since 3.0.0
*/
this.drawDebug = GetFastValue(config, 'debug', false);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#debugGraphic
* @type {null}
* @type {Phaser.GameObjects.Graphics}
* @since 3.0.0
*/
this.debugGraphic;
var _maxVelocity = GetFastValue(config, 'maxVelocity', 100);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#defaults
* @type {[type]}
* @type {object}
* @since 3.0.0
*/
this.defaults = {
@ -159,19 +150,14 @@ var World = new Class({
};
/**
* @property {object} walls - An object containing the 4 wall bodies that bound the physics world.
*/
/**
* [description]
* An object containing the 4 wall bodies that bound the physics world.
*
* @name Phaser.Physics.Impact.World#walls
* @type {[type]}
* @type {object}
* @since 3.0.0
*/
this.walls = { left: null, right: null, top: null, bottom: null };
/**
* [description]
*
@ -182,7 +168,6 @@ var World = new Class({
*/
this.delta = 0;
/**
* [description]
*
@ -225,26 +210,19 @@ var World = new Class({
},
/**
* Sets the collision map for the world either from a Weltmeister JSON level in the cache or from
* a 2D array. If loading from a Weltmeister level, the map must have a layer called "collision".
*
* @param {string|integer[][]} key - Either a string key that corresponds to a Weltmeister level
* in the cache, or a 2D array of collision IDs.
* @param {integer} tileSize - The size of a tile. This is optional if loading from a Weltmeister
* level in the cache.
* @return {CollisionMap|null} The newly created CollisionMap, or null if the method failed to
* create the CollisionMap.
*/
/**
* [description]
* Sets the collision map for the world either from a Weltmeister JSON level in the cache or from
* a 2D array. If loading from a Weltmeister level, the map must have a layer called "collision".
*
* @method Phaser.Physics.Impact.World#setCollisionMap
* @since 3.0.0
*
* @param {[type]} key - [description]
* @param {[type]} tileSize - [description]
* @param {string|integer[][]} key - Either a string key that corresponds to a Weltmeister level
* in the cache, or a 2D array of collision IDs.
* @param {integer} tileSize - The size of a tile. This is optional if loading from a Weltmeister
* level in the cache.
*
* @return {[type]} [description]
* @return {CollisionMap|null} The newly created CollisionMap, or null if the method failed to
* create the CollisionMap.
*/
setCollisionMap: function (key, tileSize)
{
@ -286,34 +264,27 @@ var World = new Class({
},
/**
* Sets the collision map for the world from a tilemap layer. Only tiles that are marked as
* colliding will be used. You can specify the mapping from tiles to slope IDs in a couple of
* ways. The easiest is to use Tiled and the slopeTileProperty option. Alternatively, you can
* manually create a slopeMap that stores the mapping between tile indices and slope IDs.
*
* @param {StaticTilemapLayer|DynamicTilemapLayer} tilemapLayer - The tilemap layer to use.
* @param {object} [options] - Options for controlling the mapping from tiles to slope IDs.
* @param {string} [options.slopeTileProperty=null] - Slope IDs can be stored on tiles directly
* using Tiled's tileset editor. If a tile has a property with the given slopeTileProperty string
* name, the value of that property for the tile will be used for its slope mapping. E.g. a 45
* degree slope upward could be given a "slope" property with a value of 2.
* @param {object} [options.slopeMap=null] - A tile index to slope definition map.
* @param {integer} [options.defaultCollidingSlope=null] - If specified, the default slope ID to
* assign to a colliding tile. If not specified, the tile's index is used.
* @param {integer} [options.defaultNonCollidingSlope=0] - The default slope ID to assign to a
* non-colliding tile.
* @return {CollisionMap} The newly created CollisionMap.
*/
/**
* [description]
* Sets the collision map for the world from a tilemap layer. Only tiles that are marked as
* colliding will be used. You can specify the mapping from tiles to slope IDs in a couple of
* ways. The easiest is to use Tiled and the slopeTileProperty option. Alternatively, you can
* manually create a slopeMap that stores the mapping between tile indices and slope IDs.
*
* @method Phaser.Physics.Impact.World#setCollisionMapFromTilemapLayer
* @since 3.0.0
*
* @param {[type]} tilemapLayer - [description]
* @param {[type]} options - [description]
* @param {StaticTilemapLayer|DynamicTilemapLayer} tilemapLayer - The tilemap layer to use.
* @param {object} [options] - Options for controlling the mapping from tiles to slope IDs.
* @param {string} [options.slopeTileProperty=null] - Slope IDs can be stored on tiles directly
* using Tiled's tileset editor. If a tile has a property with the given slopeTileProperty string
* name, the value of that property for the tile will be used for its slope mapping. E.g. a 45
* degree slope upward could be given a "slope" property with a value of 2.
* @param {object} [options.slopeMap=null] - A tile index to slope definition map.
* @param {integer} [options.defaultCollidingSlope=null] - If specified, the default slope ID to
* assign to a colliding tile. If not specified, the tile's index is used.
* @param {integer} [options.defaultNonCollidingSlope=0] - The default slope ID to assign to a
* non-colliding tile.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.CollisionMap} The newly created CollisionMap.
*/
setCollisionMapFromTilemapLayer: function (tilemapLayer, options)
{
@ -367,40 +338,27 @@ var World = new Class({
},
/**
* Sets the bounds of the Physics world to match the given world pixel dimensions.
* You can optionally set which 'walls' to create: left, right, top or bottom.
* If none of the walls are given it will default to use the walls settings it had previously.
* I.e. if you previously told it to not have the left or right walls, and you then adjust the world size
* the newly created bounds will also not have the left and right walls.
* Explicitly state them in the parameters to override this.
*
* @method Phaser.Physics.P2#setBounds
* @param {number} x - The x coordinate of the top-left corner of the bounds.
* @param {number} y - The y coordinate of the top-left corner of the bounds.
* @param {number} width - The width of the bounds.
* @param {number} height - The height of the bounds.
* @param {boolean} [left=true] - If true will create the left bounds wall.
* @param {boolean} [right=true] - If true will create the right bounds wall.
* @param {boolean} [top=true] - If true will create the top bounds wall.
* @param {boolean} [bottom=true] - If true will create the bottom bounds wall.
*/
/**
* [description]
* Sets the bounds of the Physics world to match the given world pixel dimensions.
* You can optionally set which 'walls' to create: left, right, top or bottom.
* If none of the walls are given it will default to use the walls settings it had previously.
* I.e. if you previously told it to not have the left or right walls, and you then adjust the world size
* the newly created bounds will also not have the left and right walls.
* Explicitly state them in the parameters to override this.
*
* @method Phaser.Physics.Impact.World#setBounds
* @since 3.0.0
*
* @param {[type]} x - [description]
* @param {[type]} y - [description]
* @param {[type]} width - [description]
* @param {[type]} height - [description]
* @param {[type]} thickness - [description]
* @param {[type]} left - [description]
* @param {[type]} right - [description]
* @param {[type]} top - [description]
* @param {[type]} bottom - [description]
* @param {number} [x] - The x coordinate of the top-left corner of the bounds.
* @param {number} [y] - The y coordinate of the top-left corner of the bounds.
* @param {number} [width] - The width of the bounds.
* @param {number} [height] - The height of the bounds.
* @param {number} [thickness=64] - [description]
* @param {boolean} [left=true] - If true will create the left bounds wall.
* @param {boolean} [right=true] - If true will create the right bounds wall.
* @param {boolean} [top=true] - If true will create the top bounds wall.
* @param {boolean} [bottom=true] - If true will create the bottom bounds wall.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setBounds: function (x, y, width, height, thickness, left, right, top, bottom)
{
@ -422,19 +380,18 @@ var World = new Class({
return this;
},
// position = 'left', 'right', 'top' or 'bottom'
/**
* [description]
* position = 'left', 'right', 'top' or 'bottom'
*
* @method Phaser.Physics.Impact.World#updateWall
* @since 3.0.0
*
* @param {[type]} add - [description]
* @param {[type]} position - [description]
* @param {[type]} x - [description]
* @param {[type]} y - [description]
* @param {[type]} width - [description]
* @param {[type]} height - [description]
* @param {boolean} add - [description]
* @param {string} position - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} width - [description]
* @param {number} height - [description]
*/
updateWall: function (add, position, x, y, width, height)
{
@ -471,13 +428,13 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#createDebugGraphic
* @since 3.0.0
*
* @return {[type]} [description]
* @return {Phaser.GameObjects.Graphics} [description]
*/
createDebugGraphic: function ()
{
var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 });
graphic.setZ(Number.MAX_VALUE);
graphic.setDepth(Number.MAX_VALUE);
this.debugGraphic = graphic;
@ -492,7 +449,7 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#getNextID
* @since 3.0.0
*
* @return {[type]} [description]
* @return {integer} [description]
*/
getNextID: function ()
{
@ -505,12 +462,12 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#create
* @since 3.0.0
*
* @param {[type]} x - [description]
* @param {[type]} y - [description]
* @param {[type]} sizeX - [description]
* @param {[type]} sizeY - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} sizeX - [description]
* @param {number} sizeY - [description]
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.Body} The Body that was added to this World.
*/
create: function (x, y, sizeX, sizeY)
{
@ -527,7 +484,7 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#remove
* @since 3.0.0
*
* @param {[type]} object - [description]
* @param {Phaser.Physics.Impact.Body} object - The Body to remove from this World.
*/
remove: function (object)
{
@ -540,12 +497,14 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#pause
* @since 3.0.0
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
pause: function ()
{
this.enabled = false;
this.emit('pause');
return this;
},
@ -555,12 +514,14 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#resume
* @since 3.0.0
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
resume: function ()
{
this.enabled = true;
this.emit('resume');
return this;
},
@ -570,10 +531,8 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#update
* @since 3.0.0
*
* @param {[type]} time - [description]
* @param {[type]} delta - [description]
*
* @return {[type]} [description]
* @param {number} time - [description]
* @param {number} delta - [description]
*/
update: function (time, delta)
{
@ -637,16 +596,15 @@ var World = new Class({
}
},
// Check the body against the spatial hash
/**
* [description]
* Check the body against the spatial hash.
*
* @method Phaser.Physics.Impact.World#checkHash
* @since 3.0.0
*
* @param {[type]} body - [description]
* @param {[type]} hash - [description]
* @param {[type]} size - [description]
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} hash - [description]
* @param {number} size - [description]
*/
checkHash: function (body, hash, size)
{
@ -696,10 +654,8 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#checkBodies
* @since 3.0.0
*
* @param {[type]} bodyA - [description]
* @param {[type]} bodyB - [description]
*
* @return {[type]} [description]
* @param {Phaser.Physics.Impact.Body} bodyA - [description]
* @param {Phaser.Physics.Impact.Body} bodyB - [description]
*/
checkBodies: function (bodyA, bodyB)
{
@ -726,19 +682,15 @@ var World = new Class({
}
},
// ////////////
// Helpers //
// ////////////
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCollidesNever
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCollidesNever: function (bodies)
{
@ -756,9 +708,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setLite
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setLite: function (bodies)
{
@ -776,9 +728,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setPassive
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setPassive: function (bodies)
{
@ -796,9 +748,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setActive
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setActive: function (bodies)
{
@ -816,9 +768,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setFixed
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setFixed: function (bodies)
{
@ -836,9 +788,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setTypeNone
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeNone: function (bodies)
{
@ -856,9 +808,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setTypeA
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeA: function (bodies)
{
@ -876,9 +828,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setTypeB
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeB: function (bodies)
{
@ -896,9 +848,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setAvsB
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setAvsB: function (bodies)
{
@ -917,9 +869,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setBvsA
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setBvsA: function (bodies)
{
@ -938,9 +890,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setCheckAgainstNone
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstNone: function (bodies)
{
@ -958,9 +910,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setCheckAgainstA
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstA: function (bodies)
{
@ -978,9 +930,9 @@ var World = new Class({
* @method Phaser.Physics.Impact.World#setCheckAgainstB
* @since 3.0.0
*
* @param {[type]} bodies - [description]
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {[type]} [description]
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstB: function (bodies)
{