Difference between revisions of "love.mouse.getX"

(Add an example, see also)
 
Line 9: 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.}}

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