Skip to content

Instantly share code, notes, and snippets.

@incompl
Created November 28, 2012 19:50
Show Gist options
  • Save incompl/4163667 to your computer and use it in GitHub Desktop.
Save incompl/4163667 to your computer and use it in GitHub Desktop.
body1 = new Body(physics, { color:"red", x: 15, y: 12 }).body;
body2 = new Body(physics, { image: img, x: 25, y: 12 }).body;
var def1 = new Box2D.Dynamics.Joints.b2RevoluteJointDef();
def1.Initialize(physics.world.GetGroundBody(),
body1,
body1.GetWorldCenter());
var joint1 = physics.world.CreateJoint(def1);
var def2 = new Box2D.Dynamics.Joints.b2RevoluteJointDef();
def2.Initialize(physics.world.GetGroundBody(),
body2,
body2.GetWorldCenter());
var joint2 = physics.world.CreateJoint(def2);
def = new Box2D.Dynamics.Joints.b2GearJointDef();
def.bodyA = body1;
def.bodyB = body2;
def.joint1 = joint1;
def.joint2 = joint2;
def.ratio = 2;
var joint = world.CreateJoint(def);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment