Add Joint Programmatically

Dec 13, 2011 at 2:42 PM

Hello, I am new to the Farseer Physics and the Physics Helper. I'm really affascinated by this project.
I would like to add some object to a canvas dinamically and link them togheter with joints, but I can't find a complete example of such scenario.
Maybe is trivial, but, how can I do this ? How do I add a Joint programmatically ?
Is there someone who can guide me or give me a link to some full example code ?
I'll be very grateful.
Thank you.


Jan 23, 2012 at 10:34 AM

The easiest way to do this is to hook into the Farseer code. I had to do something like this recently, in my collision event i used one of the farseer joint factories. 

       void physicsController_Collision(PhysicsSprite sprite1, PhysicsSprite sprite2)
            if (sprite1.Name == "Cage" && sprite2.Name == "GreenBall")
                    JointFactory.CreateWeldJoint(_physicsController.Simulator, sprite1.BodyObject, sprite2.BodyObject, Vector2.Zero);