2014-03-13 12:14:14 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2014 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-03-13 13:09:33 +00:00
|
|
|
* Locks the relative position between two bodies.
|
2014-03-13 12:14:14 +00:00
|
|
|
*
|
|
|
|
* @class Phaser.Physics.P2.LockConstraint
|
|
|
|
* @classdesc Physics LockConstraint Constructor
|
|
|
|
* @constructor
|
|
|
|
* @param {Phaser.Physics.P2} world - A reference to the P2 World.
|
|
|
|
* @param {p2.Body} bodyA - First connected body.
|
|
|
|
* @param {p2.Body} bodyB - Second connected body.
|
2014-03-13 13:09:33 +00:00
|
|
|
* @param {Array} [offset] - The offset of bodyB in bodyA's frame. The value is an array with 2 elements matching x and y, i.e: [32, 32].
|
|
|
|
* @param {number} [angle=0] - The angle of bodyB in bodyA's frame.
|
|
|
|
* @param {number} [maxForce] - The maximum force that should be applied to constrain the bodies.
|
2014-03-13 12:14:14 +00:00
|
|
|
*/
|
2014-03-13 13:09:33 +00:00
|
|
|
Phaser.Physics.P2.LockConstraint = function (world, bodyA, bodyB, offset, angle, maxForce) {
|
2014-03-13 12:14:14 +00:00
|
|
|
|
2014-03-13 13:09:33 +00:00
|
|
|
if (typeof offset === 'undefined') { offset = [0, 0]; }
|
2014-03-13 12:14:14 +00:00
|
|
|
if (typeof angle === 'undefined') { angle = 0; }
|
2014-03-13 13:09:33 +00:00
|
|
|
if (typeof maxForce === 'undefined') { maxForce = Number.MAX_VALUE; }
|
2014-03-13 12:14:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {Phaser.Game} game - Local reference to game.
|
|
|
|
*/
|
|
|
|
this.game = world.game;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {Phaser.Physics.P2} world - Local reference to P2 World.
|
|
|
|
*/
|
|
|
|
this.world = world;
|
|
|
|
|
2014-03-13 13:09:33 +00:00
|
|
|
offset = [ world.pxm(offset[0]), world.pxm(offset[1]) ];
|
|
|
|
|
|
|
|
var options = { localOffsetB: offset, localAngleB: angle, maxForce: maxForce };
|
2014-03-13 12:14:14 +00:00
|
|
|
|
|
|
|
p2.LockConstraint.call(this, bodyA, bodyB, options);
|
|
|
|
|
2014-03-23 06:31:26 +00:00
|
|
|
};
|
2014-03-13 12:14:14 +00:00
|
|
|
|
|
|
|
Phaser.Physics.P2.LockConstraint.prototype = Object.create(p2.LockConstraint.prototype);
|
|
|
|
Phaser.Physics.P2.LockConstraint.prototype.constructor = Phaser.Physics.P2.LockConstraint;
|