diff --git a/README.md b/README.md index d5b1f9e20..ab118c52b 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Version 2.1.0 - "Cairhien" - -in development- ### p2.js changes * DistanceConstraint signature changed to take the new localAnchors. -* +* RevoluteConstraint signature changed to include worldPivot ### New Features diff --git a/src/physics/p2/RevoluteConstraint.js b/src/physics/p2/RevoluteConstraint.js index dfdb87075..c1d927581 100644 --- a/src/physics/p2/RevoluteConstraint.js +++ b/src/physics/p2/RevoluteConstraint.js @@ -16,10 +16,12 @@ * @param {Float32Array} pivotA - The point relative to the center of mass of bodyA which bodyA is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. * @param {p2.Body} bodyB - Second connected body. * @param {Float32Array} pivotB - The point relative to the center of mass of bodyB which bodyB is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32]. +* @param {Float32Array} [worldPivot] - A pivot point given in world coordinates. If specified, localPivotA and localPivotB are automatically computed from this value. * @param {number} [maxForce=0] - The maximum force that should be applied to constrain the bodies. */ -Phaser.Physics.P2.RevoluteConstraint = function (world, bodyA, pivotA, bodyB, pivotB, maxForce) { +Phaser.Physics.P2.RevoluteConstraint = function (world, bodyA, pivotA, bodyB, pivotB, worldPivot, maxForce) { + if (typeof worldPivot === 'undefined') { worldPivot = null; } if (typeof maxForce === 'undefined') { maxForce = Number.MAX_VALUE; } /** @@ -35,7 +37,9 @@ Phaser.Physics.P2.RevoluteConstraint = function (world, bodyA, pivotA, bodyB, pi pivotA = [ world.pxmi(pivotA[0]), world.pxmi(pivotA[1]) ]; pivotB = [ world.pxmi(pivotB[0]), world.pxmi(pivotB[1]) ]; - p2.RevoluteConstraint.call(this, bodyA, pivotA, bodyB, pivotB, {maxForce: maxForce}); + var options = { worldPivot: worldPivot, localPivotA: pivotA, localPivotB: pivotB, maxForce: maxForce }; + + p2.RevoluteConstraint.call(this, bodyA, bodyB, options); };