RevoluteConstraint fixed for new version of p2.

This commit is contained in:
photonstorm 2014-08-28 00:24:56 +01:00
parent b25bdf3523
commit 4935a4e4af
2 changed files with 7 additions and 3 deletions

View file

@ -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

View file

@ -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);
};