Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by landoGriffin

I'm having trouble destroying revolute joints that i have created and keep getting the error 'd is undefined' from lib.js, does anyone have any experience/code examples of adding and removing joints to entities?

1 decade ago by alexandre

Code of how you are assembling the joint will help.

BTW, could it be that you have already destroyed one of the connected bodies prior to attempting to delete the joint?

1 decade ago by landoGriffin

Cheers for the reply but just figured it out!

I was trying to destroy the joint definition and not the actual joint, hence the errors!

For anone else looking into joints, i was creating the joint with this code:

jointDef2 = new b2.RevoluteJointDef();
jointDef2.localAnchor1.Set(25  ,110);
jointDef2.localAnchor2.Set(1.7,2.4);
jointDef2.body1 = ig.world.GetGroundBody();
jointDef2.body2 = entity.body;
ig.world.CreateJoint(jointDef2);

and then trying to destroy it with:

ig.world.DestroyJoint(jointDef2);

whereas the final line in the creation block should have been declared as a variable, so:

var spinJoint = ig.world.CreateJoint(jointDef2);

then the (working) destroy code would be:

ig.world.DestroyJoint(spinJoint);

Hopefully this helps someone not make the same stupid mistake as me!

1 decade ago by mimik

Thanks that help a lot was trying to destroy a joint but couldn't find it.

is there any easy way to draw an image or some graphics to the joint?
I have this straight line that goes back and fort between -180 and 0
The body rotates and swings quite good with the animsheet.

I tried to extend the bodys graphics to extend over the joint, but couldn't get the angle and offset to match.

Or is there a wasy way to draw some line with canvas?
Page 1 of 1
« first « previous next › last »