love.physics.newMouseJoint


Function

Synopsis

joint = love.physics.newMouseJoint( body, x, y )

Arguments

body body
The body to attach to the mouse.
number x
The x position of the connecting point.
number y
The y position of the connecting point.

Returns

Joint joint
The new mouse joint.

Examples

function love.load()
  w=love.physics.newWorld(1000,1000)
  b=love.physics.newBody(w,love.mouse.getPosition())
  s=love.physics.newCircleShape(b,0,0,20)
  b:setMassFromShapes()
  j=love.physics.newMouseJoint(b,love.mouse.getPosition())
end

function love.draw()
  love.graphics.circle("fill",b:getX(),b:getY(),s:getRadius(),20)
end

function love.update(dt)
  j:setTarget(love.mouse.getPosition())
  w:update(dt)
end

See Also