Difference between revisions of "love.mouse.getPosition"

m (Add PrettySince field.)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
 
Returns the current position of the mouse.
 
Returns the current position of the mouse.
 
== Function ==
 
== Function ==
Line 11: Line 10:
 
{{param|number|x|The position of the mouse along the x-axis.}}
 
{{param|number|x|The position of the mouse along the x-axis.}}
 
{{param|number|y|The position of the mouse along the y-axis.}}
 
{{param|number|y|The position of the mouse along the y-axis.}}
 +
== Examples ==
 +
=== Use getPosition to help draw a custom mouse image ===
 +
<source lang="lua">
 +
function love.load()
 +
  love.mouse.setVisible(false) -- make default mouse invisible
 +
  img = love.graphics.newImage("mouse.png") -- load in a custom mouse image
 +
end
 +
function love.draw()
 +
  local x, y = love.mouse.getPosition() -- get the position of the mouse
 +
  love.graphics.draw(img, x, y) -- draw the custom mouse image
 +
end
 +
</source>
 
== See Also ==
 
== See Also ==
 
* [[parent::love.mouse]]
 
* [[parent::love.mouse]]
 +
* [[love.mouse.getX]]
 +
* [[love.mouse.getY]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Returns the current position of the mouse.}}
 
{{#set:Description=Returns the current position of the mouse.}}
 +
{{#set:Since=000}}
 +
{{#set:PrettySince=0.3.2}}
 +
== Other Languages ==
 +
{{i18n|love.mouse.getPosition}}

Latest revision as of 13:10, 22 March 2015

Returns the current position of the mouse.

Function

Synopsis

x, y = love.mouse.getPosition( )

Arguments

None.

Returns

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

Examples

Use getPosition to help draw a custom mouse image

function love.load()
   love.mouse.setVisible(false) -- make default mouse invisible
   img = love.graphics.newImage("mouse.png") -- load in a custom mouse image
end
function love.draw()
   local x, y = love.mouse.getPosition() -- get the position of the mouse
   love.graphics.draw(img, x, y) -- draw the custom mouse image
end

See Also


Other Languages