mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Fixed the DistanceConstraint parameters.
This commit is contained in:
parent
504b69ffaa
commit
b25bdf3523
2 changed files with 19 additions and 3 deletions
|
@ -69,9 +69,15 @@ Version 2.1.0 - "Cairhien" - -in development-
|
|||
|
||||
### Updates
|
||||
|
||||
* Updated to the latest build of [p2.js](https://github.com/schteppe/p2.js/commit/d1c7a340c42e4d5d1d939fba5fd13c5e49d6abd2)
|
||||
* TypeScript definition updates to help fix for the `noimplicitany` option (thanks @Waog #1088)
|
||||
* All of the Pixi geom classes have been removed from the build file as they aren't needed (the Phaser.Geom classes overwrite them), saving some space in the process.
|
||||
|
||||
### p2.js changes
|
||||
|
||||
* DistanceConstraint signature changed to take the new localAnchors.
|
||||
*
|
||||
|
||||
### New Features
|
||||
|
||||
* Device will now detect for Kindle and PS Vita (thanks @lucbloom)
|
||||
|
|
|
@ -14,11 +14,16 @@
|
|||
* @param {p2.Body} bodyA - First connected body.
|
||||
* @param {p2.Body} bodyB - Second connected body.
|
||||
* @param {number} distance - The distance to keep between the bodies.
|
||||
* @param {number} [maxForce] - The maximum force that should be applied to constrain the bodies.
|
||||
* @param {Array} [localAnchorA] - The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0].
|
||||
* @param {Array} [localAnchorB] - The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0].
|
||||
* @param {object} [maxForce=Number.MAX_VALUE] - Maximum force to apply.
|
||||
*/
|
||||
Phaser.Physics.P2.DistanceConstraint = function (world, bodyA, bodyB, distance, maxForce) {
|
||||
Phaser.Physics.P2.DistanceConstraint = function (world, bodyA, bodyB, distance, localAnchorA, localAnchorB, maxForce) {
|
||||
|
||||
if (typeof distance === 'undefined') { distance = 100; }
|
||||
if (typeof localAnchorA === 'undefined') { localAnchorA = [0, 0]; }
|
||||
if (typeof localAnchorB === 'undefined') { localAnchorB = [0, 0]; }
|
||||
if (typeof maxForce === 'undefined') { maxForce = Number.MAX_VALUE; }
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
|
@ -32,7 +37,12 @@ Phaser.Physics.P2.DistanceConstraint = function (world, bodyA, bodyB, distance,
|
|||
|
||||
distance = world.pxm(distance);
|
||||
|
||||
p2.DistanceConstraint.call(this, bodyA, bodyB, distance, {maxForce: maxForce});
|
||||
localAnchorA = [ world.pxmi(localAnchorA[0]), world.pxmi(localAnchorA[1]) ];
|
||||
localAnchorB = [ world.pxmi(localAnchorB[0]), world.pxmi(localAnchorB[1]) ];
|
||||
|
||||
var options = { distance: distance, localAnchorA: localAnchorA, localAnchorB: localAnchorB, maxForce: maxForce };
|
||||
|
||||
p2.DistanceConstraint.call(this, bodyA, bodyB, options);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue