Hi,
how is it possible to create a revolte and distance joint on fly. It should work like in the game magic pen. I draw a shape, add the joint on the shape, draw a new shape which touch the joint as well as the first shape and the shapes are connected.
Has anyone did something like that or has an idea how it works??
regards
Once you draw the first shape, and it's created as a physics body, something like the following steps:
1) Users draws a joint on the shape, you add some graphics to show where the joint is, relative to the first shape/body. Save the relative position of the joint, and the body it was drawn on. There is no second body yet, so you can't add the b2Joint yet.
2) If the user draws another shape, you loop through the list of joints that have been drawn (The ones that are not yet active, but maybe the activated ones too). For each joint, check if it's inside the new body that the player just drew. Use the relative positions of the joint to the body it was drawn on, (Convert these to WorldPoints, then check if they are inside the new body). If any of the joints is inside the new shape, go ahead and create a new RevoluteJoint, connecting the two bodies.
is there a method to get the box2D postion of the mouse when I click on a body??
We have the function GetBodyAtMouse(), but this function returns a body. I need a function which returns a b2Vec2 of the mouseposition when I click.
Has anyone an idea??
regards