mirror of
https://github.com/wassname/phaser.git
synced 2026-08-19 12:30:07 +08:00
Added Phasers new Physics Manager and restored the pre-1.1.4 ArcadePhysics system. The new manager can handle multiple physics systems running in parallel, which could be extremely useful for lots of games.
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Physics manager.
|
||||
*
|
||||
* @class Phaser.Physics
|
||||
*
|
||||
* @classdesc todo
|
||||
*
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {object} [physicsConfig=null] - A physics configuration object to pass to the Physics world on creation.
|
||||
*/
|
||||
Phaser.Physics = function (game, config) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
this.config = config;
|
||||
|
||||
this.arcade = new Phaser.Physics.Arcade(game);
|
||||
|
||||
this.p2 = null;
|
||||
|
||||
this.box2d = null;
|
||||
|
||||
this.chipmunk = null;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Physics.ARCADE = 0;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Physics.P2 = 1;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Physics.BOX2D = 2;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Physics.CHIPMUNK = 3;
|
||||
|
||||
Phaser.Physics.prototype = {
|
||||
|
||||
startSystem: function (system) {
|
||||
|
||||
if (system === Phaser.Physics.ARCADE)
|
||||
{
|
||||
this.arcade = new Phaser.Physics.Arcade(this.game);
|
||||
}
|
||||
else if (system === Phaser.Physics.P2)
|
||||
{
|
||||
this.p2 = new Phaser.Physics.P2(this.game, this.config);
|
||||
}
|
||||
else if (system === Phaser.Physics.BOX2D)
|
||||
{
|
||||
// Coming soon
|
||||
}
|
||||
else if (system === Phaser.Physics.CHIPMUNK)
|
||||
{
|
||||
// Coming soon
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// Enables a sprites physics body
|
||||
enable: function (object, system) {
|
||||
|
||||
if (typeof system === 'undefined') { system = Phaser.Physics.ARCADE; }
|
||||
|
||||
var i = 1;
|
||||
|
||||
if (Array.isArray(object))
|
||||
{
|
||||
// Add to Group
|
||||
i = object.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
object = [object];
|
||||
}
|
||||
|
||||
while (i--)
|
||||
{
|
||||
if (object[i].body === null)
|
||||
{
|
||||
if (system === Phaser.Physics.ARCADE)
|
||||
{
|
||||
object[i].body = new Phaser.Physics.Arcade.Body(object[i]);
|
||||
}
|
||||
else if (system === Phaser.Physics.P2)
|
||||
{
|
||||
object[i].body = new Phaser.Physics.P2.Body(this.game, object[i], object[i].x, object[i].y, 1);
|
||||
object[i].anchor.set(0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
update: function () {
|
||||
|
||||
// ArcadePhysics doesn't have a core to update
|
||||
|
||||
if (this.p2)
|
||||
{
|
||||
this.p2.update();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
setBoundsToWorld: function () {
|
||||
|
||||
},
|
||||
|
||||
clear: function () {
|
||||
|
||||
if (this.p2)
|
||||
{
|
||||
this.p2.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Physics.prototype.constructor = Phaser.Physics;
|
||||
@@ -0,0 +1,635 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than
|
||||
* the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.
|
||||
*
|
||||
* @class Phaser.Physics.Arcade.Body
|
||||
* @classdesc Arcade Physics Body Constructor
|
||||
* @constructor
|
||||
* @param {Phaser.Sprite} sprite - The Sprite object this physics body belongs to.
|
||||
*/
|
||||
Phaser.Physics.Arcade.Body = function (sprite) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Sprite} sprite - Reference to the parent Sprite.
|
||||
*/
|
||||
this.sprite = sprite;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
*/
|
||||
this.game = sprite.game;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} offset - The offset of the Physics Body from the Sprite x/y position.
|
||||
*/
|
||||
this.offset = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {number} x - The x position of the physics body.
|
||||
* @readonly
|
||||
*/
|
||||
this.x = sprite.x;
|
||||
|
||||
/**
|
||||
* @property {number} y - The y position of the physics body.
|
||||
* @readonly
|
||||
*/
|
||||
this.y = sprite.y;
|
||||
|
||||
/**
|
||||
* @property {number} preX - The previous x position of the physics body.
|
||||
* @readonly
|
||||
*/
|
||||
this.preX = sprite.x;
|
||||
|
||||
/**
|
||||
* @property {number} preY - The previous y position of the physics body.
|
||||
* @readonly
|
||||
*/
|
||||
this.preY = sprite.y;
|
||||
|
||||
/**
|
||||
* @property {number} preRotation - The previous rotation of the physics body.
|
||||
* @readonly
|
||||
*/
|
||||
this.preRotation = sprite.angle;
|
||||
|
||||
/**
|
||||
* @property {number} screenX - The x position of the physics body translated to screen space.
|
||||
* @readonly
|
||||
*/
|
||||
this.screenX = sprite.x;
|
||||
|
||||
/**
|
||||
* @property {number} screenY - The y position of the physics body translated to screen space.
|
||||
* @readonly
|
||||
*/
|
||||
this.screenY = sprite.y;
|
||||
|
||||
/**
|
||||
* @property {number} sourceWidth - The un-scaled original size.
|
||||
* @readonly
|
||||
*/
|
||||
this.sourceWidth = sprite.texture.frame.width;
|
||||
|
||||
/**
|
||||
* @property {number} sourceHeight - The un-scaled original size.
|
||||
* @readonly
|
||||
*/
|
||||
this.sourceHeight = sprite.texture.frame.height;
|
||||
|
||||
/**
|
||||
* @property {number} width - The calculated width of the physics body.
|
||||
*/
|
||||
this.width = sprite.width;
|
||||
|
||||
/**
|
||||
* @property .numInternal ID cache
|
||||
*/
|
||||
this.height = sprite.height;
|
||||
|
||||
/**
|
||||
* @property {number} halfWidth - The calculated width / 2 of the physics body.
|
||||
*/
|
||||
this.halfWidth = Math.floor(sprite.width / 2);
|
||||
|
||||
/**
|
||||
* @property {number} halfHeight - The calculated height / 2 of the physics body.
|
||||
*/
|
||||
this.halfHeight = Math.floor(sprite.height / 2);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} center - The center coordinate of the Physics Body.
|
||||
*/
|
||||
this.center = new Phaser.Point(this.x + this.halfWidth, this.y + this.halfHeight);
|
||||
|
||||
/**
|
||||
* @property {number} _sx - Internal cache var.
|
||||
* @private
|
||||
*/
|
||||
this._sx = sprite.scale.x;
|
||||
|
||||
/**
|
||||
* @property {number} _sy - Internal cache var.
|
||||
* @private
|
||||
*/
|
||||
this._sy = sprite.scale.y;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} velocity - The velocity in pixels per second sq. of the Body.
|
||||
*/
|
||||
this.velocity = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} acceleration - The velocity in pixels per second sq. of the Body.
|
||||
*/
|
||||
this.acceleration = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} drag - The drag applied to the motion of the Body.
|
||||
*/
|
||||
this.drag = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} gravity - A private Gravity setting for the Body.
|
||||
*/
|
||||
this.gravity = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} bounce - The elasticitiy of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity.
|
||||
*/
|
||||
this.bounce = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} maxVelocity - The maximum velocity in pixels per second sq. that the Body can reach.
|
||||
* @default
|
||||
*/
|
||||
this.maxVelocity = new Phaser.Point(10000, 10000);
|
||||
|
||||
/**
|
||||
* @property {number} angularVelocity - The angular velocity in pixels per second sq. of the Body.
|
||||
* @default
|
||||
*/
|
||||
this.angularVelocity = 0;
|
||||
|
||||
/**
|
||||
* @property {number} angularAcceleration - The angular acceleration in pixels per second sq. of the Body.
|
||||
* @default
|
||||
*/
|
||||
this.angularAcceleration = 0;
|
||||
|
||||
/**
|
||||
* @property {number} angularDrag - The angular drag applied to the rotation of the Body.
|
||||
* @default
|
||||
*/
|
||||
this.angularDrag = 0;
|
||||
|
||||
/**
|
||||
* @property {number} maxAngular - The maximum angular velocity in pixels per second sq. that the Body can reach.
|
||||
* @default
|
||||
*/
|
||||
this.maxAngular = 1000;
|
||||
|
||||
/**
|
||||
* @property {number} mass - The mass of the Body.
|
||||
* @default
|
||||
*/
|
||||
this.mass = 1;
|
||||
|
||||
/**
|
||||
* @property {boolean} skipQuadTree - If the Body is an irregular shape you can set this to true to avoid it being added to any QuadTrees.
|
||||
* @default
|
||||
*/
|
||||
this.skipQuadTree = false;
|
||||
|
||||
// Allow collision
|
||||
|
||||
/**
|
||||
* Set the allowCollision properties to control which directions collision is processed for this Body.
|
||||
* For example allowCollision.up = false means it won't collide when the collision happened while moving up.
|
||||
* @property {object} allowCollision - An object containing allowed collision.
|
||||
*/
|
||||
// This would be faster as an array
|
||||
this.allowCollision = { none: false, any: true, up: true, down: true, left: true, right: true };
|
||||
|
||||
/**
|
||||
* This object is populated with boolean values when the Body collides with another.
|
||||
* touching.up = true means the collision happened to the top of this Body for example.
|
||||
* @property {object} touching - An object containing touching results.
|
||||
*/
|
||||
// This would be faster as an array
|
||||
this.touching = { none: true, up: false, down: false, left: false, right: false };
|
||||
|
||||
/**
|
||||
* This object is populated with previous touching values from the bodies previous collision.
|
||||
* @property {object} wasTouching - An object containing previous touching results.
|
||||
*/
|
||||
// This would be faster as an array
|
||||
this.wasTouching = { none: true, up: false, down: false, left: false, right: false };
|
||||
|
||||
/**
|
||||
* @property {number} facing - A const reference to the direction the Body is traveling or facing.
|
||||
* @default
|
||||
*/
|
||||
this.facing = Phaser.NONE;
|
||||
|
||||
/**
|
||||
* @property {boolean} immovable - An immovable Body will not receive any impacts from other bodies.
|
||||
* @default
|
||||
*/
|
||||
this.immovable = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} moves - Set to true to allow the Physics system to move this Body, other false to move it manually.
|
||||
* @default
|
||||
*/
|
||||
this.moves = true;
|
||||
|
||||
/**
|
||||
* @property {number} rotation - The amount the Body is rotated.
|
||||
* @default
|
||||
*/
|
||||
this.rotation = 0;
|
||||
|
||||
/**
|
||||
* @property {boolean} allowRotation - Allow this Body to be rotated? (via angularVelocity, etc)
|
||||
* @default
|
||||
*/
|
||||
this.allowRotation = true;
|
||||
|
||||
/**
|
||||
* @property {boolean} allowGravity - Allow this Body to be influenced by the global Gravity?
|
||||
* @default
|
||||
*/
|
||||
this.allowGravity = true;
|
||||
|
||||
/**
|
||||
* This flag allows you to disable the custom x separation that takes place by Physics.Arcade.separate.
|
||||
* Used in combination with your own collision processHandler you can create whatever type of collision response you need.
|
||||
* @property {boolean} customSeparateX - Use a custom separation system or the built-in one?
|
||||
* @default
|
||||
*/
|
||||
this.customSeparateX = false;
|
||||
|
||||
/**
|
||||
* This flag allows you to disable the custom y separation that takes place by Physics.Arcade.separate.
|
||||
* Used in combination with your own collision processHandler you can create whatever type of collision response you need.
|
||||
* @property {boolean} customSeparateY - Use a custom separation system or the built-in one?
|
||||
* @default
|
||||
*/
|
||||
this.customSeparateY = false;
|
||||
|
||||
/**
|
||||
* When this body collides with another, the amount of overlap is stored here.
|
||||
* @property {number} overlapX - The amount of horizontal overlap during the collision.
|
||||
*/
|
||||
this.overlapX = 0;
|
||||
|
||||
/**
|
||||
* When this body collides with another, the amount of overlap is stored here.
|
||||
* @property {number} overlapY - The amount of vertical overlap during the collision.
|
||||
*/
|
||||
this.overlapY = 0;
|
||||
|
||||
this.hull = new Phaser.Rectangle();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Rectangle} hullX - The dynamically calculated hull used during collision.
|
||||
*/
|
||||
this.hullX = new Phaser.Rectangle();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Rectangle} hullY - The dynamically calculated hull used during collision.
|
||||
*/
|
||||
this.hullY = new Phaser.Rectangle();
|
||||
|
||||
/**
|
||||
* If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true.
|
||||
* @property {boolean} embedded - Body embed value.
|
||||
*/
|
||||
this.embedded = false;
|
||||
|
||||
/**
|
||||
* A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.
|
||||
* @property {boolean} collideWorldBounds - Should the Body collide with the World bounds?
|
||||
*/
|
||||
this.collideWorldBounds = false;
|
||||
|
||||
this.blocked = { up: false, down: false, left: false, right: false };
|
||||
|
||||
};
|
||||
|
||||
Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
/**
|
||||
* Internal method.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade#updateBounds
|
||||
* @protected
|
||||
*/
|
||||
updateBounds: function (centerX, centerY, scaleX, scaleY) {
|
||||
|
||||
if (scaleX != this._sx || scaleY != this._sy)
|
||||
{
|
||||
this.width = this.sourceWidth * scaleX;
|
||||
this.height = this.sourceHeight * scaleY;
|
||||
this.halfWidth = Math.floor(this.width / 2);
|
||||
this.halfHeight = Math.floor(this.height / 2);
|
||||
this._sx = scaleX;
|
||||
this._sy = scaleY;
|
||||
this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal method.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade#preUpdate
|
||||
* @protected
|
||||
*/
|
||||
preUpdate: function () {
|
||||
|
||||
// Store and reset collision flags
|
||||
this.wasTouching.none = this.touching.none;
|
||||
this.wasTouching.up = this.touching.up;
|
||||
this.wasTouching.down = this.touching.down;
|
||||
this.wasTouching.left = this.touching.left;
|
||||
this.wasTouching.right = this.touching.right;
|
||||
|
||||
this.touching.none = true;
|
||||
this.touching.up = false;
|
||||
this.touching.down = false;
|
||||
this.touching.left = false;
|
||||
this.touching.right = false;
|
||||
|
||||
this.embedded = false;
|
||||
|
||||
this.screenX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
this.screenY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
|
||||
this.preX = (this.sprite.world.x - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
this.preY = (this.sprite.world.y - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
|
||||
this.preRotation = this.sprite.angle;
|
||||
|
||||
this.x = this.preX;
|
||||
this.y = this.preY;
|
||||
this.rotation = this.preRotation;
|
||||
|
||||
// this.overlapX = 0;
|
||||
// this.overlapY = 0;
|
||||
|
||||
this.blocked.up = false;
|
||||
this.blocked.down = false;
|
||||
this.blocked.left = false;
|
||||
this.blocked.right = false;
|
||||
|
||||
if (this.moves)
|
||||
{
|
||||
this.game.physics.arcade.updateMotion(this);
|
||||
|
||||
if (this.collideWorldBounds)
|
||||
{
|
||||
this.checkWorldBounds();
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal method.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade#postUpdate
|
||||
* @protected
|
||||
*/
|
||||
postUpdate: function () {
|
||||
|
||||
// if (this.overlapX !== 0)
|
||||
// {
|
||||
// this.x -= this.overlapX;
|
||||
// }
|
||||
|
||||
// if (this.overlapY !== 0)
|
||||
// {
|
||||
// this.y -= this.overlapY;
|
||||
// }
|
||||
|
||||
if (this.deltaX() < 0 && this.blocked.left === false)
|
||||
{
|
||||
this.facing = Phaser.LEFT;
|
||||
this.sprite.x += this.deltaX();
|
||||
}
|
||||
else if (this.deltaX() > 0 && this.blocked.right === false)
|
||||
{
|
||||
this.facing = Phaser.RIGHT;
|
||||
this.sprite.x += this.deltaX();
|
||||
}
|
||||
|
||||
if (this.deltaY() < 0 && this.blocked.up === false)
|
||||
{
|
||||
this.facing = Phaser.UP;
|
||||
this.sprite.y += this.deltaY();
|
||||
}
|
||||
else if (this.deltaY() > 0 && this.blocked.down === false)
|
||||
{
|
||||
this.facing = Phaser.DOWN;
|
||||
this.sprite.y += this.deltaY();
|
||||
}
|
||||
|
||||
this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight);
|
||||
|
||||
if (this.allowRotation)
|
||||
{
|
||||
this.sprite.angle += this.deltaZ();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal method.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade#checkWorldBounds
|
||||
* @protected
|
||||
*/
|
||||
checkWorldBounds: function () {
|
||||
|
||||
if (this.x < this.game.world.bounds.x)
|
||||
{
|
||||
this.x = this.game.world.bounds.x;
|
||||
this.velocity.x *= -this.bounce.x;
|
||||
}
|
||||
else if (this.right > this.game.world.bounds.right)
|
||||
{
|
||||
this.x = this.game.world.bounds.right - this.width;
|
||||
this.velocity.x *= -this.bounce.x;
|
||||
}
|
||||
|
||||
if (this.y < this.game.world.bounds.y)
|
||||
{
|
||||
this.y = this.game.world.bounds.y;
|
||||
this.velocity.y *= -this.bounce.y;
|
||||
}
|
||||
else if (this.bottom > this.game.world.bounds.bottom)
|
||||
{
|
||||
this.y = this.game.world.bounds.bottom - this.height;
|
||||
this.velocity.y *= -this.bounce.y;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* You can modify the size of the physics Body to be any dimension you need.
|
||||
* So it could be smaller or larger than the parent Sprite. You can also control the x and y offset, which
|
||||
* is the position of the Body relative to the top-left of the Sprite.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade#setSize
|
||||
* @param {number} width - The width of the Body.
|
||||
* @param {number} height - The height of the Body.
|
||||
* @param {number} offsetX - The X offset of the Body from the Sprite position.
|
||||
* @param {number} offsetY - The Y offset of the Body from the Sprite position.
|
||||
*/
|
||||
setSize: function (width, height, offsetX, offsetY) {
|
||||
|
||||
offsetX = offsetX || this.offset.x;
|
||||
offsetY = offsetY || this.offset.y;
|
||||
|
||||
this.sourceWidth = width;
|
||||
this.sourceHeight = height;
|
||||
this.width = this.sourceWidth * this._sx;
|
||||
this.height = this.sourceHeight * this._sy;
|
||||
this.halfWidth = Math.floor(this.width / 2);
|
||||
this.halfHeight = Math.floor(this.height / 2);
|
||||
this.offset.setTo(offsetX, offsetY);
|
||||
|
||||
this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets all Body values (velocity, acceleration, rotation, etc)
|
||||
*
|
||||
* @method Phaser.Physics.Arcade#reset
|
||||
*/
|
||||
reset: function () {
|
||||
|
||||
this.velocity.setTo(0, 0);
|
||||
this.acceleration.setTo(0, 0);
|
||||
|
||||
this.angularVelocity = 0;
|
||||
this.angularAcceleration = 0;
|
||||
this.preX = (this.sprite.world.x - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
this.preY = (this.sprite.world.y - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
this.preRotation = this.sprite.angle;
|
||||
|
||||
this.x = this.preX;
|
||||
this.y = this.preY;
|
||||
this.rotation = this.preRotation;
|
||||
|
||||
this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the absolute delta x value.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Body#deltaAbsX
|
||||
* @return {number} The absolute delta value.
|
||||
*/
|
||||
deltaAbsX: function () {
|
||||
return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX());
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the absolute delta y value.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Body#deltaAbsY
|
||||
* @return {number} The absolute delta value.
|
||||
*/
|
||||
deltaAbsY: function () {
|
||||
return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY());
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the delta x value. The difference between Body.x now and in the previous step.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Body#deltaX
|
||||
* @return {number} The delta value. Positive if the motion was to the right, negative if to the left.
|
||||
*/
|
||||
deltaX: function () {
|
||||
return this.x - this.preX;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the delta y value. The difference between Body.y now and in the previous step.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Body#deltaY
|
||||
* @return {number} The delta value. Positive if the motion was downwards, negative if upwards.
|
||||
*/
|
||||
deltaY: function () {
|
||||
return this.y - this.preY;
|
||||
},
|
||||
|
||||
deltaZ: function () {
|
||||
return this.rotation - this.preRotation;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.Arcade.Body#bottom
|
||||
* @property {number} bottom - The bottom value of this Body (same as Body.y + Body.height)
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", {
|
||||
|
||||
/**
|
||||
* The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
|
||||
* @method bottom
|
||||
* @return {number}
|
||||
*/
|
||||
get: function () {
|
||||
return Math.floor(this.y + this.height);
|
||||
},
|
||||
|
||||
/**
|
||||
* The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
|
||||
* @method bottom
|
||||
* @param {number} value
|
||||
*/
|
||||
set: function (value) {
|
||||
|
||||
if (value <= this.y)
|
||||
{
|
||||
this.height = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.height = (this.y - value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.Arcade.Body#right
|
||||
* @property {number} right - The right value of this Body (same as Body.x + Body.width)
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", {
|
||||
|
||||
/**
|
||||
* The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties.
|
||||
* However it does affect the width property.
|
||||
* @method right
|
||||
* @return {number}
|
||||
*/
|
||||
get: function () {
|
||||
return Math.floor(this.x + this.width);
|
||||
},
|
||||
|
||||
/**
|
||||
* The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties.
|
||||
* However it does affect the width property.
|
||||
* @method right
|
||||
* @param {number} value
|
||||
*/
|
||||
set: function (value) {
|
||||
|
||||
if (value <= this.x)
|
||||
{
|
||||
this.width = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.width = this.x + value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,265 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Javascript QuadTree
|
||||
* @version 1.0
|
||||
* @author Timo Hausmann
|
||||
*
|
||||
* @version 1.2, September 4th 2013
|
||||
* @author Richard Davey
|
||||
* The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
|
||||
* it massively to add node indexing, removed lots of temp. var creation and significantly
|
||||
* increased performance as a result.
|
||||
*
|
||||
* Original version at https://github.com/timohausmann/quadtree-js/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @copyright © 2012 Timo Hausmann
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* QuadTree Constructor
|
||||
*
|
||||
* @class Phaser.Physics.Arcade.QuadTree
|
||||
* @classdesc A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
|
||||
* it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. Original version at https://github.com/timohausmann/quadtree-js/
|
||||
* @constructor
|
||||
* @param {Description} physicsManager - Description.
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {number} width - The width of your game in game pixels.
|
||||
* @param {number} height - The height of your game in game pixels.
|
||||
* @param {number} maxObjects - Description.
|
||||
* @param {number} maxLevels - Description.
|
||||
* @param {number} level - Description.
|
||||
*/
|
||||
Phaser.Physics.Arcade.QuadTree = function (physicsManager, x, y, width, height, maxObjects, maxLevels, level) {
|
||||
|
||||
this.physicsManager = physicsManager;
|
||||
this.ID = physicsManager.quadTreeID;
|
||||
physicsManager.quadTreeID++;
|
||||
|
||||
this.maxObjects = maxObjects || 10;
|
||||
this.maxLevels = maxLevels || 4;
|
||||
this.level = level || 0;
|
||||
|
||||
this.bounds = {
|
||||
x: Math.round(x),
|
||||
y: Math.round(y),
|
||||
width: width,
|
||||
height: height,
|
||||
subWidth: Math.floor(width / 2),
|
||||
subHeight: Math.floor(height / 2),
|
||||
right: Math.round(x) + Math.floor(width / 2),
|
||||
bottom: Math.round(y) + Math.floor(height / 2)
|
||||
};
|
||||
|
||||
this.objects = [];
|
||||
this.nodes = [];
|
||||
|
||||
};
|
||||
|
||||
Phaser.Physics.Arcade.QuadTree.prototype = {
|
||||
|
||||
/*
|
||||
* Split the node into 4 subnodes
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.QuadTree#split
|
||||
*/
|
||||
split: function() {
|
||||
|
||||
this.level++;
|
||||
|
||||
// top right node
|
||||
this.nodes[0] = new Phaser.Physics.Arcade.QuadTree(this.physicsManager, this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
// top left node
|
||||
this.nodes[1] = new Phaser.Physics.Arcade.QuadTree(this.physicsManager, this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
// bottom left node
|
||||
this.nodes[2] = new Phaser.Physics.Arcade.QuadTree(this.physicsManager, this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
// bottom right node
|
||||
this.nodes[3] = new Phaser.Physics.Arcade.QuadTree(this.physicsManager, this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
* Insert the object into the node. If the node
|
||||
* exceeds the capacity, it will split and add all
|
||||
* objects to their corresponding subnodes.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.QuadTree#insert
|
||||
* @param {object} body - Description.
|
||||
*/
|
||||
insert: function (body) {
|
||||
|
||||
var i = 0;
|
||||
var index;
|
||||
|
||||
// if we have subnodes ...
|
||||
if (this.nodes[0] != null)
|
||||
{
|
||||
index = this.getIndex(body);
|
||||
|
||||
if (index !== -1)
|
||||
{
|
||||
this.nodes[index].insert(body);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.objects.push(body);
|
||||
|
||||
if (this.objects.length > this.maxObjects && this.level < this.maxLevels)
|
||||
{
|
||||
// Split if we don't already have subnodes
|
||||
if (this.nodes[0] == null)
|
||||
{
|
||||
this.split();
|
||||
}
|
||||
|
||||
// Add objects to subnodes
|
||||
while (i < this.objects.length)
|
||||
{
|
||||
index = this.getIndex(this.objects[i]);
|
||||
|
||||
if (index !== -1)
|
||||
{
|
||||
// this is expensive - see what we can do about it
|
||||
this.nodes[index].insert(this.objects.splice(i, 1)[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
* Determine which node the object belongs to.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.QuadTree#getIndex
|
||||
* @param {object} rect - Description.
|
||||
* @return {number} index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node.
|
||||
*/
|
||||
getIndex: function (rect) {
|
||||
|
||||
// default is that rect doesn't fit, i.e. it straddles the internal quadrants
|
||||
var index = -1;
|
||||
|
||||
if (rect.x < this.bounds.right && rect.right < this.bounds.right)
|
||||
{
|
||||
if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom))
|
||||
{
|
||||
// rect fits within the top-left quadrant of this quadtree
|
||||
index = 1;
|
||||
}
|
||||
else if ((rect.y > this.bounds.bottom))
|
||||
{
|
||||
// rect fits within the bottom-left quadrant of this quadtree
|
||||
index = 2;
|
||||
}
|
||||
}
|
||||
else if (rect.x > this.bounds.right)
|
||||
{
|
||||
// rect can completely fit within the right quadrants
|
||||
if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom))
|
||||
{
|
||||
// rect fits within the top-right quadrant of this quadtree
|
||||
index = 0;
|
||||
}
|
||||
else if ((rect.y > this.bounds.bottom))
|
||||
{
|
||||
// rect fits within the bottom-right quadrant of this quadtree
|
||||
index = 3;
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
* Return all objects that could collide with the given object.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.QuadTree#retrieve
|
||||
* @param {object} rect - Description.
|
||||
* @Return {array} - Array with all detected objects.
|
||||
*/
|
||||
retrieve: function (sprite) {
|
||||
|
||||
var returnObjects = this.objects;
|
||||
|
||||
sprite.body.quadTreeIndex = this.getIndex(sprite.body);
|
||||
|
||||
// Temp store for the node IDs this sprite is in, we can use this for fast elimination later
|
||||
sprite.body.quadTreeIDs.push(this.ID);
|
||||
|
||||
if (this.nodes[0])
|
||||
{
|
||||
// if rect fits into a subnode ..
|
||||
if (sprite.body.quadTreeIndex !== -1)
|
||||
{
|
||||
returnObjects = returnObjects.concat(this.nodes[sprite.body.quadTreeIndex].retrieve(sprite));
|
||||
}
|
||||
else
|
||||
{
|
||||
// if rect does not fit into a subnode, check it against all subnodes (unrolled for speed)
|
||||
returnObjects = returnObjects.concat(this.nodes[0].retrieve(sprite));
|
||||
returnObjects = returnObjects.concat(this.nodes[1].retrieve(sprite));
|
||||
returnObjects = returnObjects.concat(this.nodes[2].retrieve(sprite));
|
||||
returnObjects = returnObjects.concat(this.nodes[3].retrieve(sprite));
|
||||
}
|
||||
}
|
||||
|
||||
return returnObjects;
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
* Clear the quadtree.
|
||||
* @method Phaser.Physics.Arcade.QuadTree#clear
|
||||
*/
|
||||
clear: function () {
|
||||
|
||||
this.objects = [];
|
||||
|
||||
for (var i = 0, len = this.nodes.length; i < len; i++)
|
||||
{
|
||||
// if (typeof this.nodes[i] !== 'undefined')
|
||||
if (this.nodes[i])
|
||||
{
|
||||
this.nodes[i].clear();
|
||||
delete this.nodes[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -7,11 +7,11 @@
|
||||
/**
|
||||
* Collision Group
|
||||
*
|
||||
* @class Phaser.Physics.CollisionGroup
|
||||
* @class Phaser.Physics.P2.CollisionGroup
|
||||
* @classdesc Physics Collision Group Constructor
|
||||
* @constructor
|
||||
*/
|
||||
Phaser.Physics.CollisionGroup = function (bitmask) {
|
||||
Phaser.Physics.P2.CollisionGroup = function (bitmask) {
|
||||
|
||||
/**
|
||||
* @property {number} mask - The CollisionGroup bitmask.
|
||||
@@ -7,25 +7,25 @@
|
||||
/**
|
||||
* Defines a physics material
|
||||
*
|
||||
* @class Phaser.Physics.ContactMaterial
|
||||
* @class Phaser.Physics.P2.ContactMaterial
|
||||
* @classdesc Physics ContactMaterial Constructor
|
||||
* @constructor
|
||||
* @param {Phaser.Physics.Material} materialA
|
||||
* @param {Phaser.Physics.Material} materialB
|
||||
* @param {Phaser.Physics.P2.Material} materialA
|
||||
* @param {Phaser.Physics.P2.Material} materialB
|
||||
* @param {object} [options]
|
||||
*/
|
||||
Phaser.Physics.ContactMaterial = function (materialA, materialB, options) {
|
||||
Phaser.Physics.P2.ContactMaterial = function (materialA, materialB, options) {
|
||||
|
||||
/**
|
||||
* @property {number} id - The contact material identifier.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {Phaser.Physics.Material} materialA - First material participating in the contact material.
|
||||
* @property {Phaser.Physics.P2.Material} materialA - First material participating in the contact material.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {Phaser.Physics.Material} materialB - First second participating in the contact material.
|
||||
* @property {Phaser.Physics.P2.Material} materialB - First second participating in the contact material.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -60,5 +60,5 @@ Phaser.Physics.ContactMaterial = function (materialA, materialB, options) {
|
||||
|
||||
}
|
||||
|
||||
Phaser.Physics.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype);
|
||||
Phaser.Physics.ContactMaterial.prototype.constructor = Phaser.Physics.ContactMaterial;
|
||||
Phaser.Physics.P2.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype);
|
||||
Phaser.Physics.P2.ContactMaterial.prototype.constructor = Phaser.Physics.P2.ContactMaterial;
|
||||
@@ -7,26 +7,26 @@
|
||||
/**
|
||||
* A InversePointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays but inverses the values on set.
|
||||
*
|
||||
* @class Phaser.Physics.InversePointProxy
|
||||
* @class Phaser.Physics.P2.InversePointProxy
|
||||
* @classdesc InversePointProxy
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the Phaser.Game instance.
|
||||
* @param {any} destination - The object to bind to.
|
||||
*/
|
||||
Phaser.Physics.InversePointProxy = function (game, destination) {
|
||||
Phaser.Physics.P2.InversePointProxy = function (game, destination) {
|
||||
|
||||
this.game = game;
|
||||
this.destination = destination;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Physics.InversePointProxy.prototype.constructor = Phaser.Physics.InversePointProxy;
|
||||
Phaser.Physics.P2.InversePointProxy.prototype.constructor = Phaser.Physics.P2.InversePointProxy;
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.InversePointProxy#x
|
||||
* @name Phaser.Physics.P2.InversePointProxy#x
|
||||
* @property {number} x - The x property of this InversePointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.InversePointProxy.prototype, "x", {
|
||||
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -43,10 +43,10 @@ Object.defineProperty(Phaser.Physics.InversePointProxy.prototype, "x", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.InversePointProxy#y
|
||||
* @name Phaser.Physics.P2.InversePointProxy#y
|
||||
* @property {number} y - The y property of this InversePointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.InversePointProxy.prototype, "y", {
|
||||
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
/**
|
||||
* \o/ ~ "Because I'm a Material girl"
|
||||
*
|
||||
* @class Phaser.Physics.Material
|
||||
* @class Phaser.Physics.P2.Material
|
||||
* @classdesc Physics Material Constructor
|
||||
* @constructor
|
||||
*/
|
||||
Phaser.Physics.Material = function (name) {
|
||||
Phaser.Physics.P2.Material = function (name) {
|
||||
|
||||
/**
|
||||
* @property {string} name - The user defined name given to this Material.
|
||||
@@ -23,5 +23,5 @@ Phaser.Physics.Material = function (name) {
|
||||
|
||||
}
|
||||
|
||||
Phaser.Physics.Material.prototype = Object.create(p2.Material.prototype);
|
||||
Phaser.Physics.Material.prototype.constructor = Phaser.Physics.Material;
|
||||
Phaser.Physics.P2.Material.prototype = Object.create(p2.Material.prototype);
|
||||
Phaser.Physics.P2.Material.prototype.constructor = Phaser.Physics.P2.Material;
|
||||
@@ -7,26 +7,26 @@
|
||||
/**
|
||||
* A PointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays.
|
||||
*
|
||||
* @class Phaser.Physics.PointProxy
|
||||
* @class Phaser.Physics.P2.PointProxy
|
||||
* @classdesc PointProxy
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the Phaser.Game instance.
|
||||
* @param {any} destination - The object to bind to.
|
||||
*/
|
||||
Phaser.Physics.PointProxy = function (game, destination) {
|
||||
Phaser.Physics.P2.PointProxy = function (game, destination) {
|
||||
|
||||
this.game = game;
|
||||
this.destination = destination;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Physics.PointProxy.prototype.constructor = Phaser.Physics.PointProxy;
|
||||
Phaser.Physics.P2.PointProxy.prototype.constructor = Phaser.Physics.P2.PointProxy;
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.PointProxy#x
|
||||
* @name Phaser.Physics.P2.PointProxy#x
|
||||
* @property {number} x - The x property of this PointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.PointProxy.prototype, "x", {
|
||||
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -43,10 +43,10 @@ Object.defineProperty(Phaser.Physics.PointProxy.prototype, "x", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.PointProxy#y
|
||||
* @name Phaser.Physics.P2.PointProxy#y
|
||||
* @property {number} y - The y property of this PointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.PointProxy.prototype, "y", {
|
||||
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "y", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/**
|
||||
* Creates a spring, connecting two bodies.
|
||||
*
|
||||
* @class Phaser.Physics.Spring
|
||||
* @class Phaser.Physics.P2.Spring
|
||||
* @classdesc Physics Spring Constructor
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the current game.
|
||||
@@ -21,7 +21,7 @@
|
||||
* @param {Array} [localA] - Where to hook the spring to body A, in local body coordinates.
|
||||
* @param {Array} [localB] - Where to hook the spring to body B, in local body coordinates.
|
||||
*/
|
||||
Phaser.Physics.Spring = function (game, bodyA, bodyB, restLength, stiffness, damping, worldA, worldB, localA, localB) {
|
||||
Phaser.Physics.P2.Spring = function (game, bodyA, bodyB, restLength, stiffness, damping, worldA, worldB, localA, localB) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
@@ -62,5 +62,5 @@ Phaser.Physics.Spring = function (game, bodyA, bodyB, restLength, stiffness, dam
|
||||
|
||||
}
|
||||
|
||||
Phaser.Physics.Spring.prototype = Object.create(p2.Spring.prototype);
|
||||
Phaser.Physics.Spring.prototype.constructor = Phaser.Physics.Spring;
|
||||
Phaser.Physics.P2.Spring.prototype = Object.create(p2.Spring.prototype);
|
||||
Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring;
|
||||
@@ -4,29 +4,24 @@
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Phaser.Physics
|
||||
*/
|
||||
Phaser.Physics = {};
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Physics.LIME_CORONA_JSON = 0;
|
||||
Phaser.Physics.P2.LIME_CORONA_JSON = 0;
|
||||
|
||||
// Add an extra properties to p2 that we need
|
||||
p2.Body.prototype.parent = null;
|
||||
p2.Spring.prototype.parent = null;
|
||||
|
||||
/**
|
||||
* @class Phaser.Physics.World
|
||||
* @class Phaser.Physics.P2
|
||||
* @classdesc Physics World Constructor
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Reference to the current game instance.
|
||||
* @param {object} [config] - Physics configuration object passed in from the game constructor.
|
||||
*/
|
||||
Phaser.Physics.World = function (game, config) {
|
||||
Phaser.Physics.P2 = function (game, config) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
@@ -45,7 +40,7 @@ Phaser.Physics.World = function (game, config) {
|
||||
this.world = new p2.World(config);
|
||||
|
||||
/**
|
||||
* @property {array<Phaser.Physics.Material>} materials - A local array of all created Materials.
|
||||
* @property {array<Phaser.Physics.P2.Material>} materials - A local array of all created Materials.
|
||||
* @protected
|
||||
*/
|
||||
this.materials = [];
|
||||
@@ -53,7 +48,7 @@ Phaser.Physics.World = function (game, config) {
|
||||
/**
|
||||
* @property {Phaser.InversePointProxy} gravity - The gravity applied to all bodies each step.
|
||||
*/
|
||||
this.gravity = new Phaser.Physics.InversePointProxy(game, this.world.gravity);
|
||||
this.gravity = new Phaser.Physics.P2.InversePointProxy(game, this.world.gravity);
|
||||
|
||||
/**
|
||||
* @property {p2.Body} bounds - The bounds body contains the 4 walls that border the World. Define or disable with setBounds.
|
||||
@@ -149,9 +144,9 @@ Phaser.Physics.World = function (game, config) {
|
||||
*/
|
||||
this._collisionGroupID = 2;
|
||||
|
||||
this.nothingCollisionGroup = new Phaser.Physics.CollisionGroup(1);
|
||||
this.boundsCollisionGroup = new Phaser.Physics.CollisionGroup(2);
|
||||
this.everythingCollisionGroup = new Phaser.Physics.CollisionGroup(2147483648);
|
||||
this.nothingCollisionGroup = new Phaser.Physics.P2.CollisionGroup(1);
|
||||
this.boundsCollisionGroup = new Phaser.Physics.P2.CollisionGroup(2);
|
||||
this.everythingCollisionGroup = new Phaser.Physics.P2.CollisionGroup(2147483648);
|
||||
|
||||
this.boundsCollidesWith = [];
|
||||
|
||||
@@ -162,12 +157,12 @@ Phaser.Physics.World = function (game, config) {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Physics.World.prototype = {
|
||||
Phaser.Physics.P2.prototype = {
|
||||
|
||||
/**
|
||||
* Handles a p2 postStep event.
|
||||
*
|
||||
* @method Phaser.Physics.World#postStepHandler
|
||||
* @method Phaser.Physics.P2#postStepHandler
|
||||
* @private
|
||||
* @param {object} event - The event data.
|
||||
*/
|
||||
@@ -179,7 +174,7 @@ Phaser.Physics.World.prototype = {
|
||||
* Fired after the Broadphase has collected collision pairs in the world.
|
||||
* Inside the event handler, you can modify the pairs array as you like, to prevent collisions between objects that you don't want.
|
||||
*
|
||||
* @method Phaser.Physics.World#postBroadphaseHandler
|
||||
* @method Phaser.Physics.P2#postBroadphaseHandler
|
||||
* @private
|
||||
* @param {object} event - The event data.
|
||||
*/
|
||||
@@ -203,7 +198,7 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Handles a p2 impact event.
|
||||
*
|
||||
* @method Phaser.Physics.World#impactHandler
|
||||
* @method Phaser.Physics.P2#impactHandler
|
||||
* @private
|
||||
* @param {object} event - The event data.
|
||||
*/
|
||||
@@ -242,7 +237,7 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Handles a p2 begin contact event.
|
||||
*
|
||||
* @method Phaser.Physics.World#beginContactHandler
|
||||
* @method Phaser.Physics.P2#beginContactHandler
|
||||
* @private
|
||||
* @param {object} event - The event data.
|
||||
*/
|
||||
@@ -263,7 +258,7 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Handles a p2 end contact event.
|
||||
*
|
||||
* @method Phaser.Physics.World#endContactHandler
|
||||
* @method Phaser.Physics.P2#endContactHandler
|
||||
* @private
|
||||
* @param {object} event - The event data.
|
||||
*/
|
||||
@@ -302,7 +297,7 @@ Phaser.Physics.World.prototype = {
|
||||
* Sets the given material against the 4 bounds of this World.
|
||||
*
|
||||
* @method Phaser.Physics#setWorldMaterial
|
||||
* @param {Phaser.Physics.Material} material - The material to set.
|
||||
* @param {Phaser.Physics.P2.Material} material - The material to set.
|
||||
* @param {boolean} [left=true] - If true will set the material on the left bounds wall.
|
||||
* @param {boolean} [right=true] - If true will set the material on the right bounds wall.
|
||||
* @param {boolean} [top=true] - If true will set the material on the top bounds wall.
|
||||
@@ -341,7 +336,7 @@ Phaser.Physics.World.prototype = {
|
||||
* 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.
|
||||
*
|
||||
* @method Phaser.Physics.World#setBounds
|
||||
* @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.
|
||||
@@ -449,7 +444,7 @@ Phaser.Physics.World.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* @method Phaser.Physics.World#update
|
||||
* @method Phaser.Physics.P2#update
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
@@ -460,7 +455,7 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Clears all bodies from the simulation.
|
||||
*
|
||||
* @method Phaser.Physics.World#clear
|
||||
* @method Phaser.Physics.P2#clear
|
||||
*/
|
||||
clear: function () {
|
||||
|
||||
@@ -471,7 +466,7 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Clears all bodies from the simulation and unlinks World from Game. Should only be called on game shutdown. Call `clear` on a State change.
|
||||
*
|
||||
* @method Phaser.Physics.World#destroy
|
||||
* @method Phaser.Physics.P2#destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
@@ -484,8 +479,8 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Add a body to the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#addBody
|
||||
* @param {Phaser.Physics.Body} body - The Body to add to the World.
|
||||
* @method Phaser.Physics.P2#addBody
|
||||
* @param {Phaser.Physics.P2.Body} body - The Body to add to the World.
|
||||
* @return {boolean} True if the Body was added successfully, otherwise false.
|
||||
*/
|
||||
addBody: function (body) {
|
||||
@@ -508,9 +503,9 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Removes a body from the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#removeBody
|
||||
* @param {Phaser.Physics.Body} body - The Body to remove from the World.
|
||||
* @return {Phaser.Physics.Body} The Body that was removed.
|
||||
* @method Phaser.Physics.P2#removeBody
|
||||
* @param {Phaser.Physics.P2.Body} body - The Body to remove from the World.
|
||||
* @return {Phaser.Physics.P2.Body} The Body that was removed.
|
||||
*/
|
||||
removeBody: function (body) {
|
||||
|
||||
@@ -525,9 +520,9 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Adds a Spring to the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#addSpring
|
||||
* @param {Phaser.Physics.Spring} spring - The Spring to add to the World.
|
||||
* @return {Phaser.Physics.Spring} The Spring that was added.
|
||||
* @method Phaser.Physics.P2#addSpring
|
||||
* @param {Phaser.Physics.P2.Spring} spring - The Spring to add to the World.
|
||||
* @return {Phaser.Physics.P2.Spring} The Spring that was added.
|
||||
*/
|
||||
addSpring: function (spring) {
|
||||
|
||||
@@ -542,9 +537,9 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Removes a Spring from the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#removeSpring
|
||||
* @param {Phaser.Physics.Spring} spring - The Spring to remove from the World.
|
||||
* @return {Phaser.Physics.Spring} The Spring that was removed.
|
||||
* @method Phaser.Physics.P2#removeSpring
|
||||
* @param {Phaser.Physics.P2.Spring} spring - The Spring to remove from the World.
|
||||
* @return {Phaser.Physics.P2.Spring} The Spring that was removed.
|
||||
*/
|
||||
removeSpring: function (spring) {
|
||||
|
||||
@@ -559,9 +554,9 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Adds a Constraint to the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#addConstraint
|
||||
* @param {Phaser.Physics.Constraint} constraint - The Constraint to add to the World.
|
||||
* @return {Phaser.Physics.Constraint} The Constraint that was added.
|
||||
* @method Phaser.Physics.P2#addConstraint
|
||||
* @param {Phaser.Physics.P2.Constraint} constraint - The Constraint to add to the World.
|
||||
* @return {Phaser.Physics.P2.Constraint} The Constraint that was added.
|
||||
*/
|
||||
addConstraint: function (constraint) {
|
||||
|
||||
@@ -576,9 +571,9 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Removes a Constraint from the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#removeConstraint
|
||||
* @param {Phaser.Physics.Constraint} constraint - The Constraint to be removed from the World.
|
||||
* @return {Phaser.Physics.Constraint} The Constraint that was removed.
|
||||
* @method Phaser.Physics.P2#removeConstraint
|
||||
* @param {Phaser.Physics.P2.Constraint} constraint - The Constraint to be removed from the World.
|
||||
* @return {Phaser.Physics.P2.Constraint} The Constraint that was removed.
|
||||
*/
|
||||
removeConstraint: function (constraint) {
|
||||
|
||||
@@ -593,9 +588,9 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Adds a Contact Material to the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#addContactMaterial
|
||||
* @param {Phaser.Physics.ContactMaterial} material - The Contact Material to be added to the World.
|
||||
* @return {Phaser.Physics.ContactMaterial} The Contact Material that was added.
|
||||
* @method Phaser.Physics.P2#addContactMaterial
|
||||
* @param {Phaser.Physics.P2.ContactMaterial} material - The Contact Material to be added to the World.
|
||||
* @return {Phaser.Physics.P2.ContactMaterial} The Contact Material that was added.
|
||||
*/
|
||||
addContactMaterial: function (material) {
|
||||
|
||||
@@ -610,9 +605,9 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Removes a Contact Material from the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#removeContactMaterial
|
||||
* @param {Phaser.Physics.ContactMaterial} material - The Contact Material to be removed from the World.
|
||||
* @return {Phaser.Physics.ContactMaterial} The Contact Material that was removed.
|
||||
* @method Phaser.Physics.P2#removeContactMaterial
|
||||
* @param {Phaser.Physics.P2.ContactMaterial} material - The Contact Material to be removed from the World.
|
||||
* @return {Phaser.Physics.P2.ContactMaterial} The Contact Material that was removed.
|
||||
*/
|
||||
removeContactMaterial: function (material) {
|
||||
|
||||
@@ -627,10 +622,10 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Gets a Contact Material based on the two given Materials.
|
||||
*
|
||||
* @method Phaser.Physics.World#getContactMaterial
|
||||
* @param {Phaser.Physics.Material} materialA - The first Material to search for.
|
||||
* @param {Phaser.Physics.Material} materialB - The second Material to search for.
|
||||
* @return {Phaser.Physics.ContactMaterial|boolean} The Contact Material or false if none was found matching the Materials given.
|
||||
* @method Phaser.Physics.P2#getContactMaterial
|
||||
* @param {Phaser.Physics.P2.Material} materialA - The first Material to search for.
|
||||
* @param {Phaser.Physics.P2.Material} materialB - The second Material to search for.
|
||||
* @return {Phaser.Physics.P2.ContactMaterial|boolean} The Contact Material or false if none was found matching the Materials given.
|
||||
*/
|
||||
getContactMaterial: function (materialA, materialB) {
|
||||
|
||||
@@ -641,9 +636,9 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Sets the given Material against all Shapes owned by all the Bodies in the given array.
|
||||
*
|
||||
* @method Phaser.Physics.World#setMaterial
|
||||
* @param {Phaser.Physics.Material} material - The Material to be applied to the given Bodies.
|
||||
* @param {array<Phaser.Physics.Body>} bodies - An Array of Body objects that the given Material will be set on.
|
||||
* @method Phaser.Physics.P2#setMaterial
|
||||
* @param {Phaser.Physics.P2.Material} material - The Material to be applied to the given Bodies.
|
||||
* @param {array<Phaser.Physics.P2.Body>} bodies - An Array of Body objects that the given Material will be set on.
|
||||
*/
|
||||
setMaterial: function (material, bodies) {
|
||||
|
||||
@@ -661,16 +656,16 @@ Phaser.Physics.World.prototype = {
|
||||
* Materials are a way to control what happens when Shapes collide. Combine unique Materials together to create Contact Materials.
|
||||
* Contact Materials have properties such as friction and restitution that allow for fine-grained collision control between different Materials.
|
||||
*
|
||||
* @method Phaser.Physics.World#createMaterial
|
||||
* @method Phaser.Physics.P2#createMaterial
|
||||
* @param {string} [name] - Optional name of the Material. Each Material has a unique ID but string names are handy for debugging.
|
||||
* @param {Phaser.Physics.Body} [body] - Optional Body. If given it will assign the newly created Material to the Body shapes.
|
||||
* @return {Phaser.Physics.Material} The Material that was created. This is also stored in Phaser.Physics.World.materials.
|
||||
* @param {Phaser.Physics.P2.Body} [body] - Optional Body. If given it will assign the newly created Material to the Body shapes.
|
||||
* @return {Phaser.Physics.P2.Material} The Material that was created. This is also stored in Phaser.Physics.P2.materials.
|
||||
*/
|
||||
createMaterial: function (name, body) {
|
||||
|
||||
name = name || '';
|
||||
|
||||
var material = new Phaser.Physics.Material(name);
|
||||
var material = new Phaser.Physics.P2.Material(name);
|
||||
|
||||
this.materials.push(material);
|
||||
|
||||
@@ -686,18 +681,18 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Creates a Contact Material from the two given Materials. You can then edit the properties of the Contact Material directly.
|
||||
*
|
||||
* @method Phaser.Physics.World#createContactMaterial
|
||||
* @param {Phaser.Physics.Material} [materialA] - The first Material to create the ContactMaterial from. If undefined it will create a new Material object first.
|
||||
* @param {Phaser.Physics.Material} [materialB] - The second Material to create the ContactMaterial from. If undefined it will create a new Material object first.
|
||||
* @method Phaser.Physics.P2#createContactMaterial
|
||||
* @param {Phaser.Physics.P2.Material} [materialA] - The first Material to create the ContactMaterial from. If undefined it will create a new Material object first.
|
||||
* @param {Phaser.Physics.P2.Material} [materialB] - The second Material to create the ContactMaterial from. If undefined it will create a new Material object first.
|
||||
* @param {object} [options] - Material options object.
|
||||
* @return {Phaser.Physics.ContactMaterial} The Contact Material that was created.
|
||||
* @return {Phaser.Physics.P2.ContactMaterial} The Contact Material that was created.
|
||||
*/
|
||||
createContactMaterial: function (materialA, materialB, options) {
|
||||
|
||||
if (typeof materialA === 'undefined') { materialA = this.createMaterial(); }
|
||||
if (typeof materialB === 'undefined') { materialB = this.createMaterial(); }
|
||||
|
||||
var contact = new Phaser.Physics.ContactMaterial(materialA, materialB, options);
|
||||
var contact = new Phaser.Physics.P2.ContactMaterial(materialA, materialB, options);
|
||||
|
||||
return this.addContactMaterial(contact);
|
||||
|
||||
@@ -706,8 +701,8 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Populates and returns an array of all current Bodies in the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#getBodies
|
||||
* @return {array<Phaser.Physics.Body>} An array containing all current Bodies in the world.
|
||||
* @method Phaser.Physics.P2#getBodies
|
||||
* @return {array<Phaser.Physics.P2.Body>} An array containing all current Bodies in the world.
|
||||
*/
|
||||
getBodies: function () {
|
||||
|
||||
@@ -726,8 +721,8 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Populates and returns an array of all current Springs in the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#getSprings
|
||||
* @return {array<Phaser.Physics.Spring>} An array containing all current Springs in the world.
|
||||
* @method Phaser.Physics.P2#getSprings
|
||||
* @return {array<Phaser.Physics.P2.Spring>} An array containing all current Springs in the world.
|
||||
*/
|
||||
getSprings: function () {
|
||||
|
||||
@@ -746,8 +741,8 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Populates and returns an array of all current Constraints in the world.
|
||||
*
|
||||
* @method Phaser.Physics.World#getConstraints
|
||||
* @return {array<Phaser.Physics.Constraints>} An array containing all current Constraints in the world.
|
||||
* @method Phaser.Physics.P2#getConstraints
|
||||
* @return {array<Phaser.Physics.P2.Constraints>} An array containing all current Constraints in the world.
|
||||
*/
|
||||
getConstraints: function () {
|
||||
|
||||
@@ -766,7 +761,7 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Test if a world point overlaps bodies.
|
||||
*
|
||||
* @method Phaser.Physics.World#hitTest
|
||||
* @method Phaser.Physics.P2#hitTest
|
||||
* @param {Phaser.Point} worldPoint - Point to use for intersection tests.
|
||||
* @param {Array} bodies - A list of objects to check for intersection.
|
||||
* @param {number} precision - Used for matching against particles and lines. Adds some margin to these infinitesimal objects.
|
||||
@@ -779,7 +774,7 @@ Phaser.Physics.World.prototype = {
|
||||
/**
|
||||
* Converts the current world into a JSON object.
|
||||
*
|
||||
* @method Phaser.Physics.World#toJSON
|
||||
* @method Phaser.Physics.P2#toJSON
|
||||
* @return {object} A JSON representation of the world.
|
||||
*/
|
||||
toJSON: function () {
|
||||
@@ -814,7 +809,7 @@ Phaser.Physics.World.prototype = {
|
||||
|
||||
this._collisionGroupID++;
|
||||
|
||||
var group = new Phaser.Physics.CollisionGroup(bitmask);
|
||||
var group = new Phaser.Physics.P2.CollisionGroup(bitmask);
|
||||
|
||||
this.collisionGroups.push(group);
|
||||
|
||||
@@ -823,7 +818,7 @@ Phaser.Physics.World.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* @method Phaser.Physics.World.prototype.createBody
|
||||
* @method Phaser.Physics.P2.prototype.createBody
|
||||
* @param {number} x - The x coordinate of Body.
|
||||
* @param {number} y - The y coordinate of Body.
|
||||
* @param {number} mass - The mass of the Body. A mass of 0 means a 'static' Body is created.
|
||||
@@ -840,7 +835,7 @@ Phaser.Physics.World.prototype = {
|
||||
|
||||
if (typeof addToWorld === 'undefined') { addToWorld = false; }
|
||||
|
||||
var body = new Phaser.Physics.Body(this.game, null, x, y, mass);
|
||||
var body = new Phaser.Physics.P2.Body(this.game, null, x, y, mass);
|
||||
|
||||
if (data)
|
||||
{
|
||||
@@ -862,7 +857,7 @@ Phaser.Physics.World.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* @method Phaser.Physics.World.prototype.createBody
|
||||
* @method Phaser.Physics.P2.prototype.createBody
|
||||
* @param {number} x - The x coordinate of Body.
|
||||
* @param {number} y - The y coordinate of Body.
|
||||
* @param {number} mass - The mass of the Body. A mass of 0 means a 'static' Body is created.
|
||||
@@ -879,7 +874,7 @@ Phaser.Physics.World.prototype = {
|
||||
|
||||
if (typeof addToWorld === 'undefined') { addToWorld = false; }
|
||||
|
||||
var body = new Phaser.Physics.Body(this.game, null, x, y, mass);
|
||||
var body = new Phaser.Physics.P2.Body(this.game, null, x, y, mass);
|
||||
|
||||
if (data)
|
||||
{
|
||||
@@ -905,10 +900,10 @@ Phaser.Physics.World.prototype = {
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.World#friction
|
||||
* @name Phaser.Physics.P2#friction
|
||||
* @property {number} friction - Friction between colliding bodies. This value is used if no matching ContactMaterial is found for a Material pair.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.World.prototype, "friction", {
|
||||
Object.defineProperty(Phaser.Physics.P2.prototype, "friction", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -925,10 +920,10 @@ Object.defineProperty(Phaser.Physics.World.prototype, "friction", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.World#restituion
|
||||
* @name Phaser.Physics.P2#restituion
|
||||
* @property {number} restitution - Default coefficient of restitution between colliding bodies. This value is used if no matching ContactMaterial is found for a Material pair.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.World.prototype, "restituion", {
|
||||
Object.defineProperty(Phaser.Physics.P2.prototype, "restituion", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -945,10 +940,10 @@ Object.defineProperty(Phaser.Physics.World.prototype, "restituion", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.World#applySpringForces
|
||||
* @name Phaser.Physics.P2#applySpringForces
|
||||
* @property {boolean} applySpringForces - Enable to automatically apply spring forces each step.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.World.prototype, "applySpringForces", {
|
||||
Object.defineProperty(Phaser.Physics.P2.prototype, "applySpringForces", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -965,10 +960,10 @@ Object.defineProperty(Phaser.Physics.World.prototype, "applySpringForces", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.World#applyDamping
|
||||
* @name Phaser.Physics.P2#applyDamping
|
||||
* @property {boolean} applyDamping - Enable to automatically apply body damping each step.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.World.prototype, "applyDamping", {
|
||||
Object.defineProperty(Phaser.Physics.P2.prototype, "applyDamping", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -985,10 +980,10 @@ Object.defineProperty(Phaser.Physics.World.prototype, "applyDamping", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.World#applyGravity
|
||||
* @name Phaser.Physics.P2#applyGravity
|
||||
* @property {boolean} applyGravity - Enable to automatically apply gravity each step.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.World.prototype, "applyGravity", {
|
||||
Object.defineProperty(Phaser.Physics.P2.prototype, "applyGravity", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -1005,10 +1000,10 @@ Object.defineProperty(Phaser.Physics.World.prototype, "applyGravity", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.World#solveConstraints
|
||||
* @name Phaser.Physics.P2#solveConstraints
|
||||
* @property {boolean} solveConstraints - Enable/disable constraint solving in each step.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.World.prototype, "solveConstraints", {
|
||||
Object.defineProperty(Phaser.Physics.P2.prototype, "solveConstraints", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -1025,11 +1020,11 @@ Object.defineProperty(Phaser.Physics.World.prototype, "solveConstraints", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.World#time
|
||||
* @name Phaser.Physics.P2#time
|
||||
* @property {boolean} time - The World time.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.World.prototype, "time", {
|
||||
Object.defineProperty(Phaser.Physics.P2.prototype, "time", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -1040,10 +1035,10 @@ Object.defineProperty(Phaser.Physics.World.prototype, "time", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.World#emitImpactEvent
|
||||
* @name Phaser.Physics.P2#emitImpactEvent
|
||||
* @property {boolean} emitImpactEvent - Set to true if you want to the world to emit the "impact" event. Turning this off could improve performance.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.World.prototype, "emitImpactEvent", {
|
||||
Object.defineProperty(Phaser.Physics.P2.prototype, "emitImpactEvent", {
|
||||
|
||||
get: function () {
|
||||
|
||||
@@ -1060,10 +1055,10 @@ Object.defineProperty(Phaser.Physics.World.prototype, "emitImpactEvent", {
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.World#enableBodySleeping
|
||||
* @name Phaser.Physics.P2#enableBodySleeping
|
||||
* @property {boolean} enableBodySleeping - Enable / disable automatic body sleeping.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.World.prototype, "enableBodySleeping", {
|
||||
Object.defineProperty(Phaser.Physics.P2.prototype, "enableBodySleeping", {
|
||||
|
||||
get: function () {
|
||||
|
||||
Reference in New Issue
Block a user