Difference between revisions of "love.mouse.setCursor"
m (→Examples) |
(set by error french links in english page) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 27: | Line 27: | ||
<source lang="lua"> | <source lang="lua"> | ||
function love.load() | function love.load() | ||
− | + | cursor = love.mouse.getSystemCursor("hand") | |
− | + | -- Alternative: cursor = love.mouse.newCursor("pig.png", 0, 0) | |
− | -- | ||
− | |||
end | end | ||
function love.mousepressed(x, y, button) | function love.mousepressed(x, y, button) | ||
− | + | -- Use a custom cursor when the left mouse button is pressed. | |
− | + | if button == 1 then | |
− | + | love.mouse.setCursor(cursor) | |
− | + | end | |
end | end | ||
function love.mousereleased(x, y, button) | function love.mousereleased(x, y, button) | ||
− | + | -- Go back to the default cursor when the left mouse button is released. | |
− | + | if button == 1 then | |
− | + | love.mouse.setCursor() | |
− | + | end | |
end | end | ||
</source> | </source> |
Latest revision as of 00:23, 30 October 2019
Available since LÖVE 0.9.0 |
This function is not supported in earlier versions. |
Sets the current mouse cursor.
Contents
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")
-- Alternative: cursor = love.mouse.newCursor("pig.png", 0, 0)
end
function love.mousepressed(x, y, button)
-- Use a custom cursor when the left mouse button is pressed.
if button == 1 then
love.mouse.setCursor(cursor)
end
end
function love.mousereleased(x, y, button)
-- Go back to the default cursor when the left mouse button is released.
if button == 1 then
love.mouse.setCursor()
end
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info