Difference between revisions of "love.mouse.isDown"
m (mentioned in irc) |
(Updated for 0.10.0.) |
||
Line 1: | Line 1: | ||
− | Checks whether a certain mouse button is down. This function does not detect mousewheel scrolling; you must use the [[love.mousepressed]] callback for that. | + | Checks whether a certain mouse button is down. This function does not detect mousewheel scrolling; you must use the [[love.wheelmoved]] (or [[love.mousepressed]] in version [[0.9.2]] and older) callback for that. |
+ | |||
== Function == | == Function == | ||
+ | {{newin|[[0.10.0]]|100|type=variant}} | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | down = love.mouse.isDown( buttonA, buttonB, ... ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|number|buttonN|The index of a button to check. 1 is the primary mouse button, 2 is the secondary mouse button, etc.}} | ||
+ | === Returns === | ||
+ | {{param|boolean|down|True if any specified button is down.}} | ||
+ | |||
+ | == Function == | ||
+ | {{oldin|[[0.10.0]]|100|type=variant}} | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 11: | Line 24: | ||
== Function == | == Function == | ||
{{newin|[[0.7.2]]|072|type=variant}} | {{newin|[[0.7.2]]|072|type=variant}} | ||
+ | {{oldin|[[0.10.0]]|100|type=variant}} | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 20: | Line 34: | ||
{{param|boolean|anyDown|True if any specified button is down, false otherwise.}} | {{param|boolean|anyDown|True if any specified button is down, false otherwise.}} | ||
== Example == | == Example == | ||
− | === Increase a value while the right mouse button is held === | + | === Increase a value while the right mouse button is held (version [[0.10.0]] and newer) === |
+ | <source lang="lua"> | ||
+ | val = 0 -- establish a variable for later use | ||
+ | function love.update(dt) | ||
+ | if love.mouse.isDown(2) then | ||
+ | val = val + dt -- we will increase the variable by 1 for every second the button is held down | ||
+ | end | ||
+ | end | ||
+ | </source> | ||
+ | === Increase a value while the right mouse button is held (version [[0.9.2]] and older) === | ||
<source lang="lua"> | <source lang="lua"> | ||
val = 0 -- establish a variable for later use | val = 0 -- establish a variable for later use |
Revision as of 01:49, 17 December 2015
Checks whether a certain mouse button is down. This function does not detect mousewheel scrolling; you must use the love.wheelmoved (or love.mousepressed in version 0.9.2 and older) callback for that.
Function
Available since LÖVE 0.10.0 |
This variant is not supported in earlier versions. |
Synopsis
down = love.mouse.isDown( buttonA, buttonB, ... )
Arguments
number buttonN
- The index of a button to check. 1 is the primary mouse button, 2 is the secondary mouse button, etc.
Returns
boolean down
- True if any specified button is down.
Function
Removed in LÖVE 0.10.0 |
This variant is not supported in that and later versions. |
Synopsis
down = love.mouse.isDown( button )
Arguments
MouseConstant button
- The button to check.
Returns
boolean down
- True if the specified button is down.
Function
Available since LÖVE 0.7.2 |
This variant is not supported in earlier versions. |
Removed in LÖVE 0.10.0 |
This variant is not supported in that and later versions. |
Synopsis
anyDown = love.mouse.isDown( button1, button2, button3, ... )
Arguments
MouseConstant buttonN
- A button to check.
Returns
boolean anyDown
- True if any specified button is down, false otherwise.
Example
Increase a value while the right mouse button is held (version 0.10.0 and newer)
val = 0 -- establish a variable for later use
function love.update(dt)
if love.mouse.isDown(2) then
val = val + dt -- we will increase the variable by 1 for every second the button is held down
end
end
Increase a value while the right mouse button is held (version 0.9.2 and older)
val = 0 -- establish a variable for later use
function love.update(dt)
if love.mouse.isDown("r") then
val = val + dt -- we will increase the variable by 1 for every second the button is held down
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