Difference between revisions of "love.mousepressed"
m |
m (→Examples) |
||
Line 29: | Line 29: | ||
Nothing. | Nothing. | ||
== Examples == | == Examples == | ||
− | Position a string ("Text") wherever the user left-clicks | + | Position a string ("Text") wherever the user left-clicks. |
<source lang="lua"> | <source lang="lua"> | ||
function love.load() | function love.load() | ||
Line 42: | Line 42: | ||
function love.mousepressed(x, y, button, istouch) | function love.mousepressed(x, y, button, istouch) | ||
if button == 1 then -- the primary button | if button == 1 then -- the primary button | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
printx = x | printx = x | ||
printy = y | printy = y |
Revision as of 22:45, 27 December 2015
Callback function triggered when a mouse button is pressed.
Contents
Function
Available since LÖVE 0.10.0 |
This variant is not supported in earlier versions. |
Synopsis
love.mousepressed( x, y, button, istouch )
Arguments
number x
- Mouse x position, in pixels.
number y
- Mouse y position, in pixels.
number button
- The button index that was pressed. 1 is the primary button (usually left-click), 2 is the secondary button, etc.
boolean istouch
- True if the mouse button press originated from a touchscreen touch-press.
Returns
Nothing.
Notes
Use love.wheelmoved to detect mouse wheel motion. It will not register as a button press in version 0.10.0 and newer.
Function
Removed in LÖVE 0.10.0 |
This variant is not supported in that and later versions. |
Synopsis
love.mousepressed( x, y, button )
Arguments
number x
- Mouse x position.
number y
- Mouse y position.
MouseConstant button
- Mouse button pressed.
Returns
Nothing.
Examples
Position a string ("Text") wherever the user left-clicks.
function love.load()
printx = 0
printy = 0
end
function love.draw()
love.graphics.print("Text", printx, printy)
end
function love.mousepressed(x, y, button, istouch)
if button == 1 then -- the primary button
printx = x
printy = y
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