phaser/src/physics/p2/GearConstraint.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-03-13 11:13:22 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2015-02-25 03:36:23 +00:00
* @copyright 2015 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) {
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;