Dear friends,
I am able to make pulley joint between 2 bodies but don't know how to connect them with pulley rope or any simple line..
So pulley is working but line between them is not there just like invisible connection between 2 bodies..
Any body have any idea how to do that..
Thank you,
Viraj
Thank you for the helpful reply to show lines at the time of debugging..
But that is handled by the debugdraw..
Actually i want to show lines in real like ropes and all that..i am able to make ropes independently but don't know how to take ropes so that ropes just replace those three debug draw lines and change their length accordingly when pulley is up or down..
I have attached the output file
Sorry for late reply..
Thank you so much for the useful response..
hi,
you can get the position of the 2 bodies that are connected by a joint, and then draw line between them,
I am using Box2d for web, I think there is something similar in c++.
js code:
var x1 = jointRef.m_bodyA.GetPosition().x;
var y1 = jointRef.m_bodyA.GetPosition().y;
var x2 = jointRef.m_bodyB.GetPosition().x;
var y2 = jointRef.m_bodyB.GetPosition().y;
///draw line between the 2 bodies
ctx.strokeStyle = 'red';
ctx.beginPath();
ctx.lineWidth = 1;
ctx.moveTo(x1 * ScaleFactor, y1 * ScaleFactor);
ctx.lineTo(x2 * ScaleFactor, y2 * ScaleFactor);
ctx.closePath();
ctx.stroke();
It is great idea.
all the best for your work