Create a joint between a body and the mouse.

This joint actually connects the body to a fixed point in the world. To make it follow the mouse, the fixed point must be updated every timestep (example below).

The advantage of using a MouseJoint instead of just changing a body position directly is that collisions and reactions to other joints are handled by the physics engine. 

== Function ==
=== Synopsis ===
<source lang="lua">
joint = love.physics.newMouseJoint( body, x, y )
</source>
=== Arguments ===
{{param|Body|body|The body to attach to the mouse.}}
{{param|number|x|The x position of the connecting point.}}
{{param|number|y|The y position of the connecting point.}}

=== Returns ===
{{param|MouseJoint|joint|The new mouse joint.}}
== Examples ==
<source lang="lua">
function love.load()
    world = love.physics.newWorld(0, 0)
    body = love.physics.newBody(world, love.mouse.getX(), love.mouse.getY(), "dynamic")
    shape = love.physics.newCircleShape(20)
    fixture = love.physics.newFixture(body, shape)
    joint = love.physics.newMouseJoint(body, love.mouse.getPosition())
end

function love.draw()
    love.graphics.circle("fill", body:getX(), body:getY(), shape:getRadius())
end

function love.update(dt)
    joint:setTarget(love.mouse.getPosition())
    world:update(dt)
end
</source>

== See Also ==
* [[parent::love.physics]]
* [[Constructs::MouseJoint]]
* [[Constructs::Joint]]
[[Category:Functions]]
{{#set:Description=Create a joint between a body and the mouse.}}
{{#set:Since=000}}
== Other Languages ==
{{i18n|love.physics.newMouseJoint}}