Difference between revisions of "love.mouse.setVisible"

(Add an example, see also)
 
Line 9: Line 9:
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
== Examples ==
 +
Toggle mouse visibility by pressing tab.
 +
<source lang="lua">
 +
function love.keypressed(key)
 +
  if key == "tab" then
 +
      local state = not love.mouse.isVisible()  -- the opposite of whatever it currently is
 +
      love.mouse.setVisible(state)
 +
  end
 +
end
 +
</source>
 
== See Also ==
 
== See Also ==
 
* [[parent::love.mouse]]
 
* [[parent::love.mouse]]
 +
* [[love.mouse.isVisible]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Sets the current visibility of the cursor.}}
 
{{#set:Description=Sets the current visibility of the cursor.}}

Latest revision as of 13:55, 27 September 2011

Sets the current visibility of the cursor.

Function

Synopsis

love.mouse.setVisible( visible )

Arguments

boolean visible
True to set the cursor to visible, false to hide the cursor.

Returns

Nothing.

Examples

Toggle mouse visibility by pressing tab.

function love.keypressed(key)
   if key == "tab" then
      local state = not love.mouse.isVisible()   -- the opposite of whatever it currently is
      love.mouse.setVisible(state)
   end
end

See Also


Other Languages