Difference between revisions of "love.mouse.isDown"
(more functional example, more see alsos) |
|||
Line 1: | Line 1: | ||
− | Checks whether a certain button is down. | + | Checks whether a certain mouse button is down. |
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
Line 23: | Line 23: | ||
if love.mouse.isDown("r") then | if love.mouse.isDown("r") then | ||
-- do something awesome | -- do something awesome | ||
+ | end | ||
+ | </source> | ||
+ | === Increase a value while the right mouse button is held === | ||
+ | <source lang="lua"> | ||
+ | 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 | end | ||
</source> | </source> | ||
Line 28: | Line 37: | ||
* [[MouseConstant|Mouse Constant / buttons]] | * [[MouseConstant|Mouse Constant / buttons]] | ||
* [[parent::love.mouse]] | * [[parent::love.mouse]] | ||
+ | * [[love.mousepressed]] | ||
+ | * [[love.mousereleased]] | ||
+ | * [[love.keyboard.isDown]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
{{#set:Description=Checks whether a certain button is down.}} | {{#set:Description=Checks whether a certain button is down.}} |
Revision as of 16:23, 27 September 2011
Checks whether a certain mouse button is down.
Contents
Function
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. |
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
if love.mouse.isDown("r") then
-- do something awesome
end
Increase a value while the right mouse button is held
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