I need to know how I can check in Farseer Physics if a player/user clicks on a specific body, is this possible?
Do I have to write my own methods?
Use Mouse.GetState()
and compare the mouse state this frame with the state from the previous frame (you have to store it) to determine when and where clicks occur. This should be trivial, so I won't go into further detail (if you need it, ask an additional question specifically about XNA and not Farseer).
Once you have your mouse position as a Vector2
, pass it to World.TestFixture(Vector2 point)
which will return a Fixture
. (You can also use TestPointAll
to get a list of fixtures, if you want to handle having more than one under the cursor).
If you want a Body
, use the Fixture.Body
property.