Skip to content

Commit 51a2002

Browse files
committed
Merge pull request phaserjs#622 from georgiee/fix-prismatic-naming
Fixed bug in prismatic joint. Lock flag not inverted, updated naming & description
2 parents 0fca997 + c686ea0 commit 51a2002

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/physics/p2/PrismaticConstraint.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
* @param {Phaser.Physics.P2} world - A reference to the P2 World.
1414
* @param {p2.Body} bodyA - First connected body.
1515
* @param {p2.Body} bodyB - Second connected body.
16-
* @param {boolean} [lock=false] - If set to true, bodyB will be free to rotate around its anchor point.
16+
* @param {boolean} [lockRotation=true] - If set to false, bodyB will be free to rotate around its anchor point.
1717
* @param {Array} [anchorA] - Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32].
1818
* @param {Array} [anchorB] - Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32].
1919
* @param {Array} [axis] - An axis, defined in body A frame, that body B's anchor point may slide along. The value is an array with 2 elements matching x and y, i.e: [32, 32].
2020
* @param {number} [maxForce] - The maximum force that should be applied to constrain the bodies.
2121
*/
22-
Phaser.Physics.P2.PrismaticConstraint = function (world, bodyA, bodyB, lock, anchorA, anchorB, axis, maxForce) {
22+
Phaser.Physics.P2.PrismaticConstraint = function (world, bodyA, bodyB, lockRotation, anchorA, anchorB, axis, maxForce) {
2323

24-
if (typeof lock === 'undefined') { lock = false; }
24+
if (typeof lockRotation === 'undefined') { lockRotation = true; }
2525
if (typeof anchorA === 'undefined') { anchorA = [0, 0]; }
2626
if (typeof anchorB === 'undefined') { anchorB = [0, 0]; }
2727
if (typeof axis === 'undefined') { axis = [0, 0]; }
@@ -40,7 +40,7 @@ Phaser.Physics.P2.PrismaticConstraint = function (world, bodyA, bodyB, lock, anc
4040
anchorA = [ world.pxmi(anchorA[0]), world.pxmi(anchorA[1]) ];
4141
anchorB = [ world.pxmi(anchorB[0]), world.pxmi(anchorB[1]) ];
4242

43-
var options = { localAnchorA: anchorA, localAnchorB: anchorB, localAxisA: axis, maxForce: maxForce, disableRotationalLock: lock };
43+
var options = { localAnchorA: anchorA, localAnchorB: anchorB, localAxisA: axis, maxForce: maxForce, disableRotationalLock: !lockRotation };
4444

4545
p2.PrismaticConstraint.call(this, bodyA, bodyB, options);
4646

src/physics/p2/World.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -878,14 +878,14 @@ Phaser.Physics.P2.prototype = {
878878
* @method Phaser.Physics.P2#createPrismaticConstraint
879879
* @param {Phaser.Sprite|Phaser.Physics.P2.Body|p2.Body} bodyA - First connected body.
880880
* @param {Phaser.Sprite|Phaser.Physics.P2.Body|p2.Body} bodyB - Second connected body.
881-
* @param {boolean} [lock=false] - If set to true, bodyB will be free to rotate around its anchor point.
881+
* @param {boolean} [lockRotation=true] - If set to false, bodyB will be free to rotate around its anchor point.
882882
* @param {Array} [anchorA] - Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32].
883883
* @param {Array} [anchorB] - Body A's anchor point, defined in its own local frame. The value is an array with 2 elements matching x and y, i.e: [32, 32].
884884
* @param {Array} [axis] - An axis, defined in body A frame, that body B's anchor point may slide along. The value is an array with 2 elements matching x and y, i.e: [32, 32].
885885
* @param {number} [maxForce] - The maximum force that should be applied to constrain the bodies.
886886
* @return {Phaser.Physics.P2.PrismaticConstraint} The constraint
887887
*/
888-
createPrismaticConstraint: function (bodyA, bodyB, lock, anchorA, anchorB, axis, maxForce) {
888+
createPrismaticConstraint: function (bodyA, bodyB, lockRotation, anchorA, anchorB, axis, maxForce) {
889889

890890
bodyA = this.getBody(bodyA);
891891
bodyB = this.getBody(bodyB);
@@ -896,7 +896,7 @@ Phaser.Physics.P2.prototype = {
896896
}
897897
else
898898
{
899-
return this.addConstraint(new Phaser.Physics.P2.PrismaticConstraint(this, bodyA, bodyB, lock, anchorA, anchorB, axis, maxForce));
899+
return this.addConstraint(new Phaser.Physics.P2.PrismaticConstraint(this, bodyA, bodyB, lockRotation, anchorA, anchorB, axis, maxForce));
900900
}
901901

902902
},

0 commit comments

Comments
 (0)