2014-03-13 11:13:22 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2016-04-04 21:15:01 +00:00
|
|
|
* @copyright 2016 Photon Storm Ltd.
|
2014-03-13 11:13:22 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Connects two bodies at given offset points, letting them rotate relative to each other around this point.
|
|
|
|
*
|
|
|
|
* @class Phaser.Physics.P2.GearConstraint
|
|
|
|
* @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.
|
|
|
|
* @param {number} [angle=0] - The relative angle
|
|
|
|
* @param {number} [ratio=1] - The gear ratio.
|
|
|
|
*/
|
|
|
|
Phaser.Physics.P2.GearConstraint = function (world, bodyA, bodyB, angle, ratio) {
|
|
|
|
|
2015-07-22 09:37:15 +00:00
|
|
|
if (angle === undefined) { angle = 0; }
|
|
|
|
if (ratio === undefined) { ratio = 1; }
|
2014-03-13 11:13:22 +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;
|
|
|
|
|
|
|
|
var options = { angle: angle, ratio: ratio };
|
|
|
|
|
|
|
|
p2.GearConstraint.call(this, bodyA, bodyB, options);
|
|
|
|
|
2014-03-23 06:31:26 +00:00
|
|
|
};
|
2014-03-13 11:13:22 +00:00
|
|
|
|
|
|
|
Phaser.Physics.P2.GearConstraint.prototype = Object.create(p2.GearConstraint.prototype);
|
|
|
|
Phaser.Physics.P2.GearConstraint.prototype.constructor = Phaser.Physics.P2.GearConstraint;
|