Difference between revisions of "love.mousepressed"

m
m (Examples: clarification)
Line 22: Line 22:
 
end
 
end
 
function love.mousepressed(x, y, button)
 
function love.mousepressed(x, y, button)
   if button == "l" then
+
   if button == "l" then -- this is the lowercase letter L, not a one (1)
 
       printx = x
 
       printx = x
 
       printy = y
 
       printy = y
Line 28: Line 28:
 
end
 
end
 
</source>
 
</source>
 +
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]

Revision as of 22:01, 2 September 2015

Callback function triggered when a mouse button is pressed.

Function

Synopsis

love.mousepressed( x, y, button )

Arguments

number x
Mouse x position.
number y
Mouse y position.
MouseConstant button
Mouse button pressed.

Returns

Nothing.

Examples

Position a string ("Text") wherever the user left-clicks.

function love.load()
   printx = 0
   printy = 0
end
function love.draw()
   love.graphics.print("Text", printx, printy)
end
function love.mousepressed(x, y, button)
   if button == "l" then -- this is the lowercase letter L, not a one (1)
      printx = x
      printy = y
   end
end

See Also


Other Languages