Difference between revisions of "love.mouse.getX"

(Add an example, see also)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
 
Returns the current x-position of the mouse.
 
Returns the current x-position of the mouse.
 
== Function ==
 
== Function ==
Line 10: Line 9:
 
=== Returns ===
 
=== Returns ===
 
{{param|number|x|The position of the mouse along the x-axis.}}
 
{{param|number|x|The position of the mouse along the x-axis.}}
 +
== Examples ==
 +
Draw a vertical [[love.graphics.line|line]] at the mouse's x-position.
 +
<source lang="lua">
 +
function love.draw()
 +
  local x = love.mouse.getX()
 +
  love.graphics.line(x,0, x,love.graphics.getHeight())
 +
end
 +
</source>
 
== See Also ==
 
== See Also ==
 
* [[parent::love.mouse]]
 
* [[parent::love.mouse]]
 +
* [[love.mouse.getY]]
 +
* [[love.mouse.getPosition]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Returns the current x-position of the mouse.}}
 
{{#set:Description=Returns the current x-position of the mouse.}}
 +
{{#set:Since=000}}
 +
== Other Languages ==
 +
{{i18n|love.mouse.getX}}

Latest revision as of 13:48, 27 September 2011

Returns the current x-position of the mouse.

Function

Synopsis

x = love.mouse.getX( )

Arguments

None.

Returns

number x
The position of the mouse along the x-axis.

Examples

Draw a vertical line at the mouse's x-position.

function love.draw()
   local x = love.mouse.getX()
   love.graphics.line(x,0, x,love.graphics.getHeight())
end

See Also


Other Languages