Difference between revisions of "love.mouse.setCursor"

(Created page)
 
(Added simple example)
Line 23: Line 23:
 
=== Notes ===
 
=== Notes ===
 
Resets the current mouse cursor to the default.
 
Resets the current mouse cursor to the default.
 +
 +
== Examples ==
 +
<source lang="lua">
 +
function love.load()
 +
cursor = love.mouse.getSystemCursor("hand")
 +
 +
-- Or:
 +
-- cursor = love.mouse.newCursor("pig.png", 0, 0)
 +
end
 +
 +
function love.mousepressed(x, y, button)
 +
if button == "l" then
 +
-- Use a custom cursor when the left mouse button is pressed.
 +
love.mouse.setCursor(cursor)
 +
end
 +
end
 +
 +
function love.mousereleased(x, y, button)
 +
if button == "l" then
 +
-- Go back to the default cursor when the left mouse button is released.
 +
love.mouse.setCursor()
 +
end
 +
end
 +
</source>
  
 
== See Also ==
 
== See Also ==

Revision as of 21:35, 16 December 2013

Available since LÖVE 0.9.0
This function is not supported in earlier versions.

Sets the current mouse cursor.

Function

Synopsis

love.mouse.setCursor( cursor )

Arguments

Cursor cursor
The Cursor object to use as the current mouse cursor.

Returns

Nothing.

Function

Synopsis

love.mouse.setCursor( )

Arguments

None.

Returns

Nothing.

Notes

Resets the current mouse cursor to the default.

Examples

function love.load()
	cursor = love.mouse.getSystemCursor("hand")

--	Or:
--	cursor = love.mouse.newCursor("pig.png", 0, 0)
end

function love.mousepressed(x, y, button)
	if button == "l" then
		-- Use a custom cursor when the left mouse button is pressed.
		love.mouse.setCursor(cursor)
	end
end

function love.mousereleased(x, y, button)
	if button == "l" then
		-- Go back to the default cursor when the left mouse button is released.
		love.mouse.setCursor()
	end
end

See Also

Other Languages