love.mouse.setPosition

Sets the current position of the mouse.

Function

Synopsis

love.mouse.setPosition( x, y )

Arguments

number x
The new position of the mouse along the x-axis.
number y
The new position of the mouse along the y-axis.

Returns

Nothing.

Examples

Snap the mouse to a new X position when the user presses a number key. The Y position is unchanged thanks to love.mouse.getY.

function love.keypressed(key)
   if tonumber(key) then   -- if the key is numeric (0-9), execute the next line
	  love.mouse.setPosition(tonumber(key) * 10,  love.mouse.getY())   -- multiply the key by 10 to make the effect more visible, maintain the Y position via getY
   end
end

See Also


Other Languages