Pulley joint in box2dWeb-2.1.a.3.js library

A simple example of how to make a pulley joint in box2dWeb-2.1.a.3.js library.
    var pulleyJoint = new b2PulleyJointDef(); 
	var body1_anchor = new b2Vec2(2.25, 6);  // the pulley point attachment to body1
	var body2_anchor = new b2Vec2(9.75, 6);  // the pulley point attachment to body2
	var ground1_anchor = new b2Vec2(2,3);  // the pulley point 1 attachment to the world ground
	var ground2_anchor = new b2Vec2(10,3); // the pulley point 2 attachment to the world ground
	var ratio = 1; // the ratio between both bodies
	
	    pulleyJoint.Initialize(box1, box2, ground1_anchor, ground2_anchor, body1_anchor, body2_anchor, ratio);
	
	    world.CreateJoint(pulleyJoint); 

Responses

0 Replies