mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Merge pull request #4063 from samme/docs/arcade-physics-2
Arcade Physics docs
This commit is contained in:
commit
314e5a496a
10 changed files with 273 additions and 195 deletions
|
@ -105,7 +105,7 @@ var Sprite = require('../sprite/Sprite');
|
|||
* @constructor
|
||||
* @since 3.0.0
|
||||
* @param {Phaser.Scene} scene - The scene this group belongs to.
|
||||
* @param {(Phaser.GameObjects.GameObject[]|GroupConfig)} [children] - Game objects to add to this group; or the `config` argument.
|
||||
* @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument.
|
||||
* @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. If `key` is set, Phaser.GameObjects.Group#createMultiple is also called with these settings.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Group
|
||||
|
|
|
@ -15,18 +15,19 @@ var PluginCache = require('../../plugins/PluginCache');
|
|||
var Vector2 = require('../../math/Vector2');
|
||||
var World = require('./World');
|
||||
|
||||
// All methods in this class are available under `this.physics` in a Scene.
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* [description]
|
||||
* The Arcade Physics Plugin belongs to a Scene and sets up and manages the Scene's physics simulation.
|
||||
* It also holds some useful methods for moving and rotating Arcade Physics Bodies.
|
||||
*
|
||||
* You can access it from within a Scene using `this.physics`.
|
||||
*
|
||||
* @class ArcadePhysics
|
||||
* @memberOf Phaser.Physics.Arcade
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {Phaser.Scene} scene - The Scene that this Plugin belongs to.
|
||||
*/
|
||||
var ArcadePhysics = new Class({
|
||||
|
||||
|
@ -35,7 +36,7 @@ var ArcadePhysics = new Class({
|
|||
function ArcadePhysics (scene)
|
||||
{
|
||||
/**
|
||||
* [description]
|
||||
* The Scene that this Plugin belongs to.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.ArcadePhysics#scene
|
||||
* @type {Phaser.Scene}
|
||||
|
@ -44,7 +45,7 @@ var ArcadePhysics = new Class({
|
|||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Scene's Systems.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.ArcadePhysics#systems
|
||||
* @type {Phaser.Scenes.Systems}
|
||||
|
@ -53,7 +54,7 @@ var ArcadePhysics = new Class({
|
|||
this.systems = scene.sys;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A configuration object. Union of the `physics.arcade.*` properties of the GameConfig and SceneConfig objects.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.ArcadePhysics#config
|
||||
* @type {object}
|
||||
|
@ -62,7 +63,7 @@ var ArcadePhysics = new Class({
|
|||
this.config = this.getConfig();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The physics simulation.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.ArcadePhysics#world
|
||||
* @type {Phaser.Physics.Arcade.World}
|
||||
|
@ -71,7 +72,7 @@ var ArcadePhysics = new Class({
|
|||
this.world;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An object holding the Arcade Physics factory methods.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.ArcadePhysics#add
|
||||
* @type {Phaser.Physics.Arcade.Factory}
|
||||
|
@ -124,12 +125,12 @@ var ArcadePhysics = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Creates the physics configuration for the current Scene.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.ArcadePhysics#getConfig
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {object} [description]
|
||||
* @return {object} The physics configuration.
|
||||
*/
|
||||
getConfig: function ()
|
||||
{
|
||||
|
@ -145,31 +146,20 @@ var ArcadePhysics = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body.
|
||||
*
|
||||
* Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results.
|
||||
*
|
||||
* Both the first and second parameter can be arrays of objects, of differing types.
|
||||
* If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter.
|
||||
*
|
||||
* ##### Tilemaps
|
||||
*
|
||||
* Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful.
|
||||
*
|
||||
* If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1).
|
||||
*
|
||||
* If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like.
|
||||
* Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap}
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.ArcadePhysics#overlap
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @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 {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 {ArcadeColliderType} object1 - The first object or array of objects to check.
|
||||
* @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`.
|
||||
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
|
||||
* @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `collideCallback` will only be called if this callback returns `true`.
|
||||
* @param {*} [callbackContext] - The context in which to run the callbacks.
|
||||
*
|
||||
* @return {boolean} True if an overlap occurred otherwise false.
|
||||
* @return {boolean} True if at least one Game Object overlaps another.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.World#overlap
|
||||
*/
|
||||
overlap: function (object1, object2, overlapCallback, processCallback, callbackContext)
|
||||
{
|
||||
|
@ -181,18 +171,20 @@ var ArcadePhysics = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Tests if Game Objects overlap and separates them (if possible). See {@link Phaser.Physics.Arcade.World#collide}.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.ArcadePhysics#collide
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @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 {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 {ArcadeColliderType} object1 - The first object or array of objects to check.
|
||||
* @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`.
|
||||
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
|
||||
* @param {ArcadePhysicsCallback} [processCallback] - An optional 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 {*} [callbackContext] - The context in which to run the callbacks.
|
||||
*
|
||||
* @return {boolean} True if a collision occurred otherwise false.
|
||||
* @return {boolean} True if any overlapping Game Objects were separated, otherwise false.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.World#collide
|
||||
*/
|
||||
collide: function (object1, object2, collideCallback, processCallback, callbackContext)
|
||||
{
|
||||
|
@ -204,12 +196,12 @@ var ArcadePhysics = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Pauses the simulation.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.ArcadePhysics#pause
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.World} [description]
|
||||
* @return {Phaser.Physics.Arcade.World} The simulation.
|
||||
*/
|
||||
pause: function ()
|
||||
{
|
||||
|
@ -217,12 +209,12 @@ var ArcadePhysics = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Resumes the simulation (if paused).
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.ArcadePhysics#resume
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.World} [description]
|
||||
* @return {Phaser.Physics.Arcade.World} The simulation.
|
||||
*/
|
||||
resume: function ()
|
||||
{
|
||||
|
|
|
@ -35,6 +35,8 @@ var Vector2 = require('../../math/Vector2');
|
|||
* @classdesc
|
||||
* A Dynamic Arcade Body.
|
||||
*
|
||||
* Its static counterpart is {@link Phaser.Physics.Arcade.StaticBody}.
|
||||
*
|
||||
* @class Body
|
||||
* @memberOf Phaser.Physics.Arcade
|
||||
* @constructor
|
||||
|
@ -136,8 +138,8 @@ var Body = new Class({
|
|||
this.isCircle = false;
|
||||
|
||||
/**
|
||||
* The unscaled radius of this Body's boundary (if circular), as set by setCircle, in source pixels.
|
||||
* The true radius (if circular) is equal to halfWidth.
|
||||
* If this Body is circular, this is the unscaled radius of the Body's boundary, as set by setCircle(), in source pixels.
|
||||
* The true radius is equal to `halfWidth`.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#radius
|
||||
* @type {number}
|
||||
|
@ -176,7 +178,7 @@ var Body = new Class({
|
|||
this.prev = new Vector2(gameObject.x, gameObject.y);
|
||||
|
||||
/**
|
||||
* Whether this Body's rotation is affected by its angular acceleration and velocity.
|
||||
* Whether this Body's `rotation` is affected by its angular acceleration and angular velocity.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#allowRotation
|
||||
* @type {boolean}
|
||||
|
@ -186,7 +188,7 @@ var Body = new Class({
|
|||
this.allowRotation = true;
|
||||
|
||||
/**
|
||||
* This body's rotation, in degrees, based on its angular acceleration and velocity.
|
||||
* This body's rotation, in degrees, based on its angular acceleration and angular velocity.
|
||||
* The Body's rotation controls the `angle` of its Game Object.
|
||||
* It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle.
|
||||
*
|
||||
|
@ -206,7 +208,8 @@ var Body = new Class({
|
|||
this.preRotation = gameObject.angle;
|
||||
|
||||
/**
|
||||
* The width of the Body's boundary. If circular, this is also the Body's diameter.
|
||||
* The width of the Body's boundary, in pixels.
|
||||
* If the Body is circular, this is also the Body's diameter.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#width
|
||||
* @type {number}
|
||||
|
@ -216,7 +219,8 @@ var Body = new Class({
|
|||
this.width = width;
|
||||
|
||||
/**
|
||||
* The height of the Body's boundary. If circular, this is also the Body's diameter.
|
||||
* The height of the Body's boundary, in pixels.
|
||||
* If the Body is circular, this is also the Body's diameter.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#height
|
||||
* @type {number}
|
||||
|
@ -226,7 +230,8 @@ var Body = new Class({
|
|||
this.height = height;
|
||||
|
||||
/**
|
||||
* The unscaled width of the Body, in source pixels. The default is the width of the Body's Game Object's texture frame.
|
||||
* The unscaled width of the Body, in source pixels, as set by setSize().
|
||||
* The default is the width of the Body's Game Object's texture frame.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#sourceWidth
|
||||
* @type {number}
|
||||
|
@ -236,7 +241,8 @@ var Body = new Class({
|
|||
this.sourceWidth = width;
|
||||
|
||||
/**
|
||||
* The unscaled height of the Body, in source pixels. The default is the height of the Body's Game Object's texture frame.
|
||||
* The unscaled height of the Body, in source pixels, as set by setSize().
|
||||
* The default is the height of the Body's Game Object's texture frame.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#sourceHeight
|
||||
* @type {number}
|
||||
|
@ -252,7 +258,7 @@ var Body = new Class({
|
|||
}
|
||||
|
||||
/**
|
||||
* Half the Body's width.
|
||||
* Half the Body's width, in pixels.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#halfWidth
|
||||
* @type {number}
|
||||
|
@ -261,7 +267,7 @@ var Body = new Class({
|
|||
this.halfWidth = Math.abs(width / 2);
|
||||
|
||||
/**
|
||||
* Half the Body's height.
|
||||
* Half the Body's height, in pixels.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#halfHeight
|
||||
* @type {number}
|
||||
|
@ -270,7 +276,8 @@ var Body = new Class({
|
|||
this.halfHeight = Math.abs(height / 2);
|
||||
|
||||
/**
|
||||
* The center of the Body's boundary. The midpoint of its `position` (top-left corner) and its bottom-right corner.
|
||||
* The center of the Body's boundary.
|
||||
* The midpoint of its `position` (top-left corner) and its bottom-right corner.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#center
|
||||
* @type {Phaser.Math.Vector2}
|
||||
|
@ -279,7 +286,7 @@ var Body = new Class({
|
|||
this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight);
|
||||
|
||||
/**
|
||||
* The Body's change in position, in pixels per second.
|
||||
* The Body's velocity, in pixels per second.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#velocity
|
||||
* @type {Phaser.Math.Vector2}
|
||||
|
@ -288,7 +295,7 @@ var Body = new Class({
|
|||
this.velocity = new Vector2();
|
||||
|
||||
/**
|
||||
* The Body's calculated change in position, in pixels, at the last step.
|
||||
* The Body's calculated velocity, in pixels per second, at the last step.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#newVelocity
|
||||
* @type {Phaser.Math.Vector2}
|
||||
|
@ -316,7 +323,7 @@ var Body = new Class({
|
|||
this.acceleration = new Vector2();
|
||||
|
||||
/**
|
||||
* Whether this Body's velocity is affected by its drag vector.
|
||||
* Whether this Body's velocity is affected by its `drag`.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#allowDrag
|
||||
* @type {boolean}
|
||||
|
@ -327,20 +334,30 @@ var Body = new Class({
|
|||
|
||||
/**
|
||||
* Absolute loss of velocity due to movement, in pixels per second squared.
|
||||
* The x and y components are applied separately.
|
||||
*
|
||||
* When `useDamping` is true, this is 1 minus the damping factor.
|
||||
* A value of 1 means the Body loses no velocity.
|
||||
* A value of 0.95 means the Body loses 5% of its velocity per step.
|
||||
* A value of 0.5 means the Body loses 50% of its velocity per step.
|
||||
*
|
||||
* Drag is applied only when `acceleration` is zero.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#drag
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @type {(Phaser.Math.Vector2|number)}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.drag = new Vector2();
|
||||
|
||||
/**
|
||||
* Whether this Body's position is affected by its gravity vector.
|
||||
* Whether this Body's position is affected by gravity (local or world).
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#allowGravity
|
||||
* @type {boolean}
|
||||
* @default true
|
||||
* @since 3.0.0
|
||||
* @see Phaser.Physics.Arcade.Body#gravity
|
||||
* @see Phaser.Physics.Arcade.World#gravity
|
||||
*/
|
||||
this.allowGravity = true;
|
||||
|
||||
|
@ -351,6 +368,7 @@ var Body = new Class({
|
|||
* @name Phaser.Physics.Arcade.Body#gravity
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @since 3.0.0
|
||||
* @see Phaser.Physics.Arcade.World#gravity
|
||||
*/
|
||||
this.gravity = new Vector2();
|
||||
|
||||
|
@ -365,7 +383,7 @@ var Body = new Class({
|
|||
|
||||
/**
|
||||
* Rebound following a collision with the world boundary, relative to 1.
|
||||
* If empty, `bounce` is used instead.
|
||||
* If null, `bounce` is used instead.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#worldBounce
|
||||
* @type {?Phaser.Math.Vector2}
|
||||
|
@ -410,9 +428,8 @@ var Body = new Class({
|
|||
this.onOverlap = false;
|
||||
|
||||
/**
|
||||
* The Body's absolute maximum velocity.
|
||||
*
|
||||
* This limits the Body's rate of movement but not its `velocity` values (which can still exceed `maxVelocity`).
|
||||
* The Body's absolute maximum velocity, in pixels per second.
|
||||
* The horizontal and vertical components are applied separately.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#maxVelocity
|
||||
* @type {Phaser.Math.Vector2}
|
||||
|
@ -421,8 +438,10 @@ var Body = new Class({
|
|||
this.maxVelocity = new Vector2(10000, 10000);
|
||||
|
||||
/**
|
||||
* If this Body is `immovable` and in motion, this the proportion of this Body's movement received by the riding body on each axis, relative to 1.
|
||||
* The default value (1, 0) moves the riding body horizontally in equal proportion and vertically not at all.
|
||||
* If this Body is `immovable` and in motion, `friction` is the proportion of this Body's motion received by the riding Body on each axis, relative to 1.
|
||||
* The default value (1, 0) moves the riding Body horizontally in equal proportion to this Body and vertically not at all.
|
||||
* The horizontal component (x) is applied only when two colliding Bodies are separated vertically.
|
||||
* The vertical component (y) is applied only when two colliding Bodies are separated horizontally.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#friction
|
||||
* @type {Phaser.Math.Vector2}
|
||||
|
@ -449,7 +468,7 @@ var Body = new Class({
|
|||
this.useDamping = false;
|
||||
|
||||
/**
|
||||
* The rate of change of this Body's rotation, in degrees per second.
|
||||
* The rate of change of this Body's `rotation`, in degrees per second.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#angularVelocity
|
||||
* @type {number}
|
||||
|
@ -459,7 +478,7 @@ var Body = new Class({
|
|||
this.angularVelocity = 0;
|
||||
|
||||
/**
|
||||
* The rate of change of this Body's angular velocity, in degrees per second squared.
|
||||
* The Body's angular acceleration (change in angular velocity), in degrees per second squared.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#angularAcceleration
|
||||
* @type {number}
|
||||
|
@ -471,6 +490,8 @@ var Body = new Class({
|
|||
/**
|
||||
* Loss of angular velocity due to angular movement, in degrees per second.
|
||||
*
|
||||
* Angular drag is applied only when angular acceleration is zero.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#angularDrag
|
||||
* @type {number}
|
||||
* @default 0
|
||||
|
@ -500,7 +521,7 @@ var Body = new Class({
|
|||
this.mass = 1;
|
||||
|
||||
/**
|
||||
* The angle of this Body's velocity vector, in degrees.
|
||||
* The calculated angle of this Body's velocity vector, in degrees, during the last step.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#angle
|
||||
* @type {number}
|
||||
|
@ -510,7 +531,7 @@ var Body = new Class({
|
|||
this.angle = 0;
|
||||
|
||||
/**
|
||||
* The magnitude of the Body's velocity, as calculated during the last update.
|
||||
* The calculated magnitude of the Body's velocity, in pixels per second, during the last step.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#speed
|
||||
* @type {number}
|
||||
|
@ -520,7 +541,8 @@ var Body = new Class({
|
|||
this.speed = 0;
|
||||
|
||||
/**
|
||||
* The calculated direction of the Body's velocity.
|
||||
* The direction of the Body's velocity, as calculated during the last step.
|
||||
* If the Body is moving on both axes (diagonally), this describes motion on the vertical axis only.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#facing
|
||||
* @type {integer}
|
||||
|
@ -529,7 +551,7 @@ var Body = new Class({
|
|||
this.facing = CONST.FACING_NONE;
|
||||
|
||||
/**
|
||||
* Whether this object can be moved by collisions with another body.
|
||||
* Whether this Body can be moved by collisions with another Body.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#immovable
|
||||
* @type {boolean}
|
||||
|
@ -549,7 +571,8 @@ var Body = new Class({
|
|||
this.moves = true;
|
||||
|
||||
/**
|
||||
* A flag disabling the default horizontal separation of colliding bodies. Pass your own `processHandler` to the collider.
|
||||
* A flag disabling the default horizontal separation of colliding bodies.
|
||||
* Pass your own `collideCallback` to the collider.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#customSeparateX
|
||||
* @type {boolean}
|
||||
|
@ -559,7 +582,8 @@ var Body = new Class({
|
|||
this.customSeparateX = false;
|
||||
|
||||
/**
|
||||
* A flag disabling the default vertical separation of colliding bodies. Pass your own `processHandler` to the collider.
|
||||
* A flag disabling the default vertical separation of colliding bodies.
|
||||
* Pass your own `collideCallback` to the collider.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#customSeparateY
|
||||
* @type {boolean}
|
||||
|
@ -730,7 +754,7 @@ var Body = new Class({
|
|||
this._sy = gameObject.scaleY;
|
||||
|
||||
/**
|
||||
* The calculated change in the Body's horizontal position during the current step.
|
||||
* The calculated change in the Body's horizontal position during the last step.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#_dx
|
||||
* @type {number}
|
||||
|
@ -741,7 +765,7 @@ var Body = new Class({
|
|||
this._dx = 0;
|
||||
|
||||
/**
|
||||
* The calculated change in the Body's vertical position during the current step.
|
||||
* The calculated change in the Body's vertical position during the last step.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Body#_dy
|
||||
* @type {number}
|
||||
|
@ -833,7 +857,7 @@ var Body = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Updates the Body's `center` from its `position` and dimensions.
|
||||
* Updates the Body's `center` from its `position`, `width`, and `height`.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Body#updateCenter
|
||||
* @since 3.0.0
|
||||
|
@ -1099,7 +1123,7 @@ var Body = new Class({
|
|||
{
|
||||
height = gameObject.frame.realHeight;
|
||||
}
|
||||
|
||||
|
||||
this.sourceWidth = width;
|
||||
this.sourceHeight = height;
|
||||
|
||||
|
|
|
@ -101,8 +101,8 @@ var Factory = new Class({
|
|||
* @method Phaser.Physics.Arcade.Factory#existing
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {boolean} [isStatic=false] - Set to true to create a Static body, otherwise it will create a Dynamic body.
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - A Game Object.
|
||||
* @param {boolean} [isStatic=false] - Create a Static body (true) or Dynamic body (false).
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object.
|
||||
*/
|
||||
|
@ -220,8 +220,8 @@ var Factory = new Class({
|
|||
* @method Phaser.Physics.Arcade.Factory#staticGroup
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object|object[]} [children] - [description]
|
||||
* @param {GroupConfig} [config] - [description]
|
||||
* @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument.
|
||||
* @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group.
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created.
|
||||
*/
|
||||
|
@ -237,8 +237,8 @@ var Factory = new Class({
|
|||
* @method Phaser.Physics.Arcade.Factory#group
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object|object[]} [children] - [description]
|
||||
* @param {PhysicsGroupConfig} [config] - [description]
|
||||
* @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument.
|
||||
* @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group.
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.Group} The Group object that was created.
|
||||
*/
|
||||
|
|
|
@ -41,34 +41,36 @@ var IsPlainObject = require('../../utils/object/IsPlainObject');
|
|||
/**
|
||||
* @typedef {object} PhysicsGroupDefaults
|
||||
*
|
||||
* @property {boolean} setCollideWorldBounds - [description]
|
||||
* @property {number} setAccelerationX - [description]
|
||||
* @property {number} setAccelerationY - [description]
|
||||
* @property {boolean} setAllowDrag - [description]
|
||||
* @property {boolean} setAllowGravity - [description]
|
||||
* @property {boolean} setAllowRotation - [description]
|
||||
* @property {number} setBounceX - [description]
|
||||
* @property {number} setBounceY - [description]
|
||||
* @property {number} setDragX - [description]
|
||||
* @property {number} setDragY - [description]
|
||||
* @property {number} setGravityX - [description]
|
||||
* @property {number} setGravityY - [description]
|
||||
* @property {number} setFrictionX - [description]
|
||||
* @property {number} setFrictionY - [description]
|
||||
* @property {number} setVelocityX - [description]
|
||||
* @property {number} setVelocityY - [description]
|
||||
* @property {number} setAngularVelocity - [description]
|
||||
* @property {number} setAngularAcceleration - [description]
|
||||
* @property {number} setAngularDrag - [description]
|
||||
* @property {number} setMass - [description]
|
||||
* @property {boolean} setImmovable - [description]
|
||||
* @property {boolean} setCollideWorldBounds - As {@link Phaser.Physics.Arcade.Body#setCollideWorldBounds}.
|
||||
* @property {number} setAccelerationX - As {@link Phaser.Physics.Arcade.Body#setAccelerationX}.
|
||||
* @property {number} setAccelerationY - As {@link Phaser.Physics.Arcade.Body#setAccelerationY}.
|
||||
* @property {boolean} setAllowDrag - As {@link Phaser.Physics.Arcade.Body#setAllowDrag}.
|
||||
* @property {boolean} setAllowGravity - As {@link Phaser.Physics.Arcade.Body#setAllowGravity}.
|
||||
* @property {boolean} setAllowRotation - As {@link Phaser.Physics.Arcade.Body#setAllowRotation}.
|
||||
* @property {number} setBounceX - As {@link Phaser.Physics.Arcade.Body#setBounceX}.
|
||||
* @property {number} setBounceY - As {@link Phaser.Physics.Arcade.Body#setBounceY}.
|
||||
* @property {number} setDragX - As {@link Phaser.Physics.Arcade.Body#setDragX}.
|
||||
* @property {number} setDragY - As {@link Phaser.Physics.Arcade.Body#setDragY}.
|
||||
* @property {number} setGravityX - As {@link Phaser.Physics.Arcade.Body#setGravityX}.
|
||||
* @property {number} setGravityY - As {@link Phaser.Physics.Arcade.Body#setGravityY}.
|
||||
* @property {number} setFrictionX - As {@link Phaser.Physics.Arcade.Body#setFrictionX}.
|
||||
* @property {number} setFrictionY - As {@link Phaser.Physics.Arcade.Body#setFrictionY}.
|
||||
* @property {number} setVelocityX - As {@link Phaser.Physics.Arcade.Body#setVelocityX}.
|
||||
* @property {number} setVelocityY - As {@link Phaser.Physics.Arcade.Body#setVelocityY}.
|
||||
* @property {number} setAngularVelocity - As {@link Phaser.Physics.Arcade.Body#setAngularVelocity}.
|
||||
* @property {number} setAngularAcceleration - As {@link Phaser.Physics.Arcade.Body#setAngularAcceleration}.
|
||||
* @property {number} setAngularDrag - As {@link Phaser.Physics.Arcade.Body#setAngularDrag}.
|
||||
* @property {number} setMass - As {@link Phaser.Physics.Arcade.Body#setMass}.
|
||||
* @property {boolean} setImmovable - As {@link Phaser.Physics.Arcade.Body#setImmovable}.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* An Arcade Physics Group object.
|
||||
*
|
||||
* All Game Objects created by this Group will automatically be dynamic Arcade Physics objects.
|
||||
* All Game Objects created by this Group will automatically be given dynamic Arcade Physics bodies.
|
||||
*
|
||||
* Its static counterpart is {@link Phaser.Physics.Arcade.StaticGroup}.
|
||||
*
|
||||
* @class Group
|
||||
* @extends Phaser.GameObjects.Group
|
||||
|
@ -76,10 +78,10 @@ var IsPlainObject = require('../../utils/object/IsPlainObject');
|
|||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Physics.Arcade.World} world - [description]
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {array} children - [description]
|
||||
* @param {PhysicsGroupConfig} [config] - [description]
|
||||
* @param {Phaser.Physics.Arcade.World} world - The physics simulation.
|
||||
* @param {Phaser.Scene} scene - The scene this group belongs to.
|
||||
* @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument.
|
||||
* @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group.
|
||||
*/
|
||||
var PhysicsGroup = new Class({
|
||||
|
||||
|
@ -119,7 +121,7 @@ var PhysicsGroup = new Class({
|
|||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The physics simulation.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Group#world
|
||||
* @type {Phaser.Physics.Arcade.World}
|
||||
|
@ -129,24 +131,26 @@ var PhysicsGroup = new Class({
|
|||
|
||||
/**
|
||||
* The class to create new group members from.
|
||||
* This should be ArcadeImage, ArcadeSprite, or a class extending one of those.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Group#classType
|
||||
* @type {Phaser.Physics.Arcade.Sprite}
|
||||
* @type {(Phaser.Physics.Arcade.Image|Phaser.Physics.Arcade.Sprite)}
|
||||
* @default ArcadeSprite
|
||||
*/
|
||||
config.classType = GetFastValue(config, 'classType', ArcadeSprite);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The physics type of the Group's members.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Group#physicsType
|
||||
* @type {integer}
|
||||
* @default DYNAMIC_BODY
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.physicsType = CONST.DYNAMIC_BODY;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.Group#defaults
|
||||
* @type {PhysicsGroupDefaults}
|
||||
|
@ -180,12 +184,12 @@ var PhysicsGroup = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Enables a Game Object's Body and assigns `defaults`. Called when a Group member is added or created.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Group#createCallbackHandler
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} child - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} child - The Game Object being added.
|
||||
*/
|
||||
createCallbackHandler: function (child)
|
||||
{
|
||||
|
@ -203,12 +207,12 @@ var PhysicsGroup = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Disables a Game Object's Body. Called when a Group member is removed.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Group#removeCallbackHandler
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} child - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} child - The Game Object being removed.
|
||||
*/
|
||||
removeCallbackHandler: function (child)
|
||||
{
|
||||
|
@ -219,14 +223,14 @@ var PhysicsGroup = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sets the velocity of each Group member.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Group#setVelocity
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {number} step - [description]
|
||||
* @param {number} x - The horizontal velocity.
|
||||
* @param {number} y - The vertical velocity.
|
||||
* @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x, y), the second (x + step, y + step), and so on.
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.Group} This Physics Group object.
|
||||
*/
|
||||
|
@ -245,13 +249,13 @@ var PhysicsGroup = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sets the horizontal velocity of each Group member.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Group#setVelocityX
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} value - [description]
|
||||
* @param {number} step - [description]
|
||||
* @param {number} value - The velocity value.
|
||||
* @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x), the second (x + step), and so on.
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.Group} This Physics Group object.
|
||||
*/
|
||||
|
@ -270,13 +274,13 @@ var PhysicsGroup = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sets the vertical velocity of each Group member.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Group#setVelocityY
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} value - [description]
|
||||
* @param {number} step - [description]
|
||||
* @param {number} value - The velocity value.
|
||||
* @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (y), the second (y + step), and so on.
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.Group} This Physics Group object.
|
||||
*/
|
||||
|
|
|
@ -12,7 +12,14 @@ var Vector2 = require('../../math/Vector2');
|
|||
|
||||
/**
|
||||
* @classdesc
|
||||
* [description]
|
||||
* A Static Arcade Physics Body.
|
||||
*
|
||||
* A Static Body never moves, and isn't automatically synchronized with its parent Game Object.
|
||||
* That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually.
|
||||
*
|
||||
* A Static Body can collide with other Bodies, but is never moved by collisions.
|
||||
*
|
||||
* Its dynamic counterpart is {@link Phaser.Physics.Arcade.Body}.
|
||||
*
|
||||
* @class StaticBody
|
||||
* @memberOf Phaser.Physics.Arcade
|
||||
|
@ -165,6 +172,7 @@ var StaticBody = new Class({
|
|||
*
|
||||
* @name Phaser.Physics.Arcade.StaticBody#velocity
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.velocity = Vector2.ZERO;
|
||||
|
@ -174,6 +182,7 @@ var StaticBody = new Class({
|
|||
*
|
||||
* @name Phaser.Physics.Arcade.StaticBody#allowGravity
|
||||
* @type {boolean}
|
||||
* @readOnly
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -184,6 +193,7 @@ var StaticBody = new Class({
|
|||
*
|
||||
* @name Phaser.Physics.Arcade.StaticBody#gravity
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.gravity = Vector2.ZERO;
|
||||
|
@ -193,6 +203,7 @@ var StaticBody = new Class({
|
|||
*
|
||||
* @name Phaser.Physics.Arcade.StaticBody#bounce
|
||||
* @type {Phaser.Math.Vector2}
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.bounce = Vector2.ZERO;
|
||||
|
@ -401,6 +412,8 @@ var StaticBody = new Class({
|
|||
* @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object?
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.StaticBody} This Static Body object.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject
|
||||
*/
|
||||
setGameObject: function (gameObject, update)
|
||||
{
|
||||
|
@ -593,7 +606,8 @@ var StaticBody = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Resets this StaticBody to the given coordinates. Does not reposition its parent Game Object
|
||||
* Updates this Static Body's position based on the current Game Object it is bound to.
|
||||
* Similar to `updateFromGameObject`, but doesn't modify the Body's dimensions.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.StaticBody#reset
|
||||
* @since 3.0.0
|
||||
|
@ -721,7 +735,7 @@ var StaticBody = new Class({
|
|||
* @method Phaser.Physics.Arcade.StaticBody#deltaY
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {number} 0
|
||||
*/
|
||||
deltaY: function ()
|
||||
{
|
||||
|
@ -734,7 +748,7 @@ var StaticBody = new Class({
|
|||
* @method Phaser.Physics.Arcade.StaticBody#deltaZ
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {number} 0
|
||||
*/
|
||||
deltaZ: function ()
|
||||
{
|
||||
|
@ -742,7 +756,7 @@ var StaticBody = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Disables the StaticBody and marks it to be destroyed.
|
||||
* Disables this Body and marks it for destruction during the next step.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.StaticBody#destroy
|
||||
* @since 3.0.0
|
||||
|
|
|
@ -12,7 +12,11 @@ var IsPlainObject = require('../../utils/object/IsPlainObject');
|
|||
|
||||
/**
|
||||
* @classdesc
|
||||
* [description]
|
||||
* An Arcade Physics Static Group object.
|
||||
*
|
||||
* All Game Objects created by this Group will automatically be given static Arcade Physics bodies.
|
||||
*
|
||||
* Its dynamic counterpart is {@link Phaser.Physics.Arcade.Group}.
|
||||
*
|
||||
* @class StaticGroup
|
||||
* @extends Phaser.GameObjects.Group
|
||||
|
@ -20,10 +24,10 @@ var IsPlainObject = require('../../utils/object/IsPlainObject');
|
|||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Physics.Arcade.World} world - [description]
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {array} children - [description]
|
||||
* @param {GroupConfig} config - [description]
|
||||
* @param {Phaser.Physics.Arcade.World} world - The physics simulation.
|
||||
* @param {Phaser.Scene} scene - The scene this group belongs to.
|
||||
* @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument.
|
||||
* @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group.
|
||||
*/
|
||||
var StaticPhysicsGroup = new Class({
|
||||
|
||||
|
@ -69,7 +73,7 @@ var StaticPhysicsGroup = new Class({
|
|||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The physics simulation.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.StaticGroup#world
|
||||
* @type {Phaser.Physics.Arcade.World}
|
||||
|
@ -78,10 +82,11 @@ var StaticPhysicsGroup = new Class({
|
|||
this.world = world;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The scene this group belongs to.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.StaticGroup#physicsType
|
||||
* @type {integer}
|
||||
* @default STATIC_BODY
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.physicsType = CONST.STATIC_BODY;
|
||||
|
@ -90,12 +95,14 @@ var StaticPhysicsGroup = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.StaticGroup#createCallbackHandler
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} child - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} child - The new group member.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.World#enableBody
|
||||
*/
|
||||
createCallbackHandler: function (child)
|
||||
{
|
||||
|
@ -106,12 +113,14 @@ var StaticPhysicsGroup = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Disables the group member's physics body, removing it from the simulation.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.StaticGroup#removeCallbackHandler
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} child - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} child - The group member being removed.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.World#disableBody
|
||||
*/
|
||||
removeCallbackHandler: function (child)
|
||||
{
|
||||
|
@ -122,12 +131,14 @@ var StaticPhysicsGroup = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Refreshes the group.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallbackHandler
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} entries - [description]
|
||||
* @param {Phaser.GameObjects.GameObject[]} entries - The newly created group members.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.StaticGroup#refresh
|
||||
*/
|
||||
createMultipleCallbackHandler: function ()
|
||||
{
|
||||
|
@ -135,12 +146,15 @@ var StaticPhysicsGroup = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Resets each Body to the position of its parent Game Object.
|
||||
* Body sizes aren't changed (use {@link Phaser.Physics.Arcade.Components.Enable#refreshBody} for that).
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.StaticGroup#refresh
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.StaticGroup} [description]
|
||||
* @return {Phaser.Physics.Arcade.StaticGroup} This group.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.StaticBody#reset
|
||||
*/
|
||||
refresh: function ()
|
||||
{
|
||||
|
|
|
@ -127,7 +127,7 @@ var Wrap = require('../../math/Wrap');
|
|||
|
||||
/**
|
||||
* An Arcade Physics Collider Type.
|
||||
*
|
||||
*
|
||||
* @typedef {(
|
||||
* Phaser.GameObjects.GameObject|
|
||||
* Phaser.GameObjects.Group|
|
||||
|
@ -258,7 +258,7 @@ var World = new Class({
|
|||
|
||||
/**
|
||||
* The number of physics steps to be taken per second.
|
||||
*
|
||||
*
|
||||
* This property is read-only. Use the `setFPS` method to modify it at run-time.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.World#fps
|
||||
|
@ -317,7 +317,7 @@ var World = new Class({
|
|||
* - 0.5 = double speed
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.World#timeScale
|
||||
* @property {number}
|
||||
* @property {number}
|
||||
* @default 1
|
||||
* @since 3.10.0
|
||||
*/
|
||||
|
@ -417,7 +417,7 @@ var World = new Class({
|
|||
|
||||
/**
|
||||
* The maximum number of items per node on the RTree.
|
||||
*
|
||||
*
|
||||
* This is ignored if `useTree` is `false`. If you have a large number of bodies in
|
||||
* your world then you may find search performance improves by increasing this value,
|
||||
* to allow more items per node and less node division.
|
||||
|
@ -431,7 +431,7 @@ var World = new Class({
|
|||
|
||||
/**
|
||||
* Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not?
|
||||
*
|
||||
*
|
||||
* An RTree is a fast way of spatially sorting of all the moving bodies in the world.
|
||||
* However, at certain limits, the cost of clearing and inserting the bodies into the
|
||||
* tree every frame becomes more expensive than the search speed gains it provides.
|
||||
|
@ -507,7 +507,7 @@ var World = new Class({
|
|||
|
||||
/**
|
||||
* Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group.
|
||||
*
|
||||
*
|
||||
* The difference between this and the `enableBody` method is that you can pass arrays or Groups
|
||||
* to this method.
|
||||
*
|
||||
|
@ -633,7 +633,7 @@ var World = new Class({
|
|||
* @since 3.10.0
|
||||
*
|
||||
* @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be added to the simulation.
|
||||
*
|
||||
*
|
||||
* @return {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} The Body that was added to the simulation.
|
||||
*/
|
||||
add: function (body)
|
||||
|
@ -656,10 +656,10 @@ var World = new Class({
|
|||
|
||||
/**
|
||||
* Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group.
|
||||
*
|
||||
*
|
||||
* The difference between this and the `disableBody` method is that you can pass arrays or Groups
|
||||
* to this method.
|
||||
*
|
||||
*
|
||||
* The body itself is not deleted, it just has its `enable` property set to false, which
|
||||
* means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`.
|
||||
*
|
||||
|
@ -1748,11 +1748,11 @@ var World = new Class({
|
|||
* @method Phaser.Physics.Arcade.World#overlap
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {ArcadeColliderType} object1 - [description]
|
||||
* @param {ArcadeColliderType} [object2] - [description]
|
||||
* @param {ArcadePhysicsCallback} [overlapCallback] - [description]
|
||||
* @param {ArcadePhysicsCallback} [processCallback] - [description]
|
||||
* @param {*} [callbackContext] - The context of where you want the callbacks to point to, e.g: `this`.
|
||||
* @param {ArcadeColliderType} object1 - The first object or array of objects to check.
|
||||
* @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`.
|
||||
* @param {ArcadePhysicsCallback} [overlapCallback] - An optional callback function that is called if the objects overlap.
|
||||
* @param {ArcadePhysicsCallback} [processCallback] - An optional 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 {*} [callbackContext] - The context in which to run the callbacks.
|
||||
*
|
||||
* @return {boolean} True if at least one Game Object overlaps another.
|
||||
*/
|
||||
|
@ -1770,7 +1770,7 @@ var World = new Class({
|
|||
* Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups.
|
||||
*
|
||||
* If you don't require separation then use {@link #overlap} instead.
|
||||
*
|
||||
*
|
||||
* If two Groups or arrays are passed, each member of one will be tested against each member of the other.
|
||||
*
|
||||
* If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members.
|
||||
|
@ -1786,13 +1786,13 @@ var World = new Class({
|
|||
* @method Phaser.Physics.Arcade.World#collide
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {ArcadeColliderType} object1 - [description]
|
||||
* @param {ArcadeColliderType} [object2] - [description]
|
||||
* @param {ArcadePhysicsCallback} [collideCallback] - [description]
|
||||
* @param {ArcadePhysicsCallback} [processCallback] - [description]
|
||||
* @param {*} [callbackContext] - [description]
|
||||
* @param {ArcadeColliderType} object1 - The first object or array of objects to check.
|
||||
* @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`.
|
||||
* @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide.
|
||||
* @param {ArcadePhysicsCallback} [processCallback] - An optional 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 {*} [callbackContext] - The context in which to run the callbacks.
|
||||
*
|
||||
* @return {boolean} True if any overlapping Game Objects were separated.
|
||||
* @return {boolean} True if any overlapping Game Objects were separated, otherwise false.
|
||||
*/
|
||||
collide: function (object1, object2, collideCallback, processCallback, callbackContext)
|
||||
{
|
||||
|
@ -1816,7 +1816,7 @@ var World = new Class({
|
|||
* @param {*} callbackContext - [description]
|
||||
* @param {boolean} overlapOnly - [description]
|
||||
*
|
||||
* @return {boolean} True if any overlapping objects were separated.
|
||||
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
|
||||
*/
|
||||
collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly)
|
||||
{
|
||||
|
@ -1886,7 +1886,7 @@ var World = new Class({
|
|||
* @param {*} callbackContext - [description]
|
||||
* @param {boolean} overlapOnly - [description]
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated.
|
||||
*/
|
||||
collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly)
|
||||
{
|
||||
|
|
|
@ -13,18 +13,25 @@
|
|||
var Enable = {
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Enables this Game Object's Body.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Components.Enable#enableBody
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} reset - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {boolean} enableGameObject - [description]
|
||||
* @param {boolean} showGameObject - [description]
|
||||
* @param {boolean} reset - Also reset the Body and place it at (x, y).
|
||||
* @param {number} x - The horizontal position to place the Game Object and Body.
|
||||
* @param {number} y - The horizontal position to place the Game Object and Body.
|
||||
* @param {boolean} enableGameObject - Also activate this Game Object.
|
||||
* @param {boolean} showGameObject - Also show this Game Object.
|
||||
*
|
||||
* @return {this} This Game Object.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Body#enable
|
||||
* @see Phaser.Physics.Arcade.StaticBody#enable
|
||||
* @see Phaser.Physics.Arcade.Body#reset
|
||||
* @see Phaser.Physics.Arcade.StaticBody#reset
|
||||
* @see Phaser.GameObjects.GameObject#active
|
||||
* @see Phaser.GameObjects.GameObject#visible
|
||||
*/
|
||||
enableBody: function (reset, x, y, enableGameObject, showGameObject)
|
||||
{
|
||||
|
@ -49,15 +56,20 @@ var Enable = {
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Stops and disables this Game Object's Body.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Components.Enable#disableBody
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} [disableGameObject=false] - [description]
|
||||
* @param {boolean} [hideGameObject=false] - [description]
|
||||
* @param {boolean} [disableGameObject=false] - Also deactivate this Game Object.
|
||||
* @param {boolean} [hideGameObject=false] - Also hide this Game Object.
|
||||
*
|
||||
* @return {this} This Game Object.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Body#enable
|
||||
* @see Phaser.Physics.Arcade.StaticBody#enable
|
||||
* @see Phaser.GameObjects.GameObject#active
|
||||
* @see Phaser.GameObjects.GameObject#visible
|
||||
*/
|
||||
disableBody: function (disableGameObject, hideGameObject)
|
||||
{
|
||||
|
@ -82,7 +94,7 @@ var Enable = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Syncs the Bodies position and size with its parent Game Object.
|
||||
* Syncs the Body's position and size with its parent Game Object.
|
||||
* You don't need to call this for Dynamic Bodies, as it happens automatically.
|
||||
* But for Static bodies it's a useful way of modifying the position of a Static Body
|
||||
* in the Physics World, based on its Game Object.
|
||||
|
@ -91,6 +103,8 @@ var Enable = {
|
|||
* @since 3.1.0
|
||||
*
|
||||
* @return {this} This Game Object.
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject
|
||||
*/
|
||||
refreshBody: function ()
|
||||
{
|
||||
|
|
|
@ -6,35 +6,41 @@
|
|||
|
||||
/**
|
||||
* Arcade Physics consts.
|
||||
*
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
var CONST = {
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* Dynamic Body.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.DYNAMIC_BODY
|
||||
* @readOnly
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Body#physicsType
|
||||
* @see Phaser.Physics.Arcade.Group#physicsType
|
||||
*/
|
||||
DYNAMIC_BODY: 0,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* Static Body.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.STATIC_BODY
|
||||
* @readOnly
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Body#physicsType
|
||||
* @see Phaser.Physics.Arcade.StaticBody#physicsType
|
||||
*/
|
||||
STATIC_BODY: 1,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.GROUP
|
||||
* @readOnly
|
||||
* @type {number}
|
||||
|
@ -44,7 +50,7 @@ var CONST = {
|
|||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.TILEMAPLAYER
|
||||
* @readOnly
|
||||
* @type {number}
|
||||
|
@ -53,52 +59,62 @@ var CONST = {
|
|||
TILEMAPLAYER: 3,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* Facing no direction (initial value).
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.FACING_NONE
|
||||
* @readOnly
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Body#facing
|
||||
*/
|
||||
FACING_NONE: 10,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* Facing up.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.FACING_UP
|
||||
* @readOnly
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Body#facing
|
||||
*/
|
||||
FACING_UP: 11,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* Facing down.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.FACING_DOWN
|
||||
* @readOnly
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Body#facing
|
||||
*/
|
||||
FACING_DOWN: 12,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* Facing left.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.FACING_LEFT
|
||||
* @readOnly
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Body#facing
|
||||
*/
|
||||
FACING_LEFT: 13,
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* Facing right.
|
||||
*
|
||||
* @name Phaser.Physics.Arcade.FACING_RIGHT
|
||||
* @readOnly
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @see Phaser.Physics.Arcade.Body#facing
|
||||
*/
|
||||
FACING_RIGHT: 14
|
||||
|
||||
|
|
Loading…
Reference in a new issue