Difference between revisions of "love.mousereleased"

m (Updated for 0.10.0.)
m (Examples)
Line 29: Line 29:
  
 
== Examples ==
 
== Examples ==
Position a string ("Text") wherever the user releases the primary mouse button (version [[0.10.0]] and newer).
+
Position a string ("Text") wherever the user releases the primary mouse button.
 
<source lang="lua">
 
<source lang="lua">
 
function love.load()
 
function love.load()
Line 41: Line 41:
  
 
function love.mousereleased(x, y, button)
 
function love.mousereleased(x, y, button)
   if button == "l" then
+
   if button == 1 then
 
       printx = x
 
       printx = x
 
       printy = y
 
       printy = y
Line 47: Line 47:
 
end
 
end
 
</source>
 
</source>
----
 
Position a string ("Text") wherever the user releases the primary mouse button (version [[0.9.2]] and older).
 
<source lang="lua">
 
function love.load()
 
  printx = 0
 
  printy = 0
 
end
 
  
function love.draw()
 
  love.graphics.print("Text", printx, printy)
 
end
 
 
function love.mousereleased(x, y, button)
 
  if button == "l" then
 
      printx = x
 
      printy = y
 
  end
 
end
 
</source>
 
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]

Revision as of 22:45, 27 December 2015

Callback function triggered when a mouse button is released.

Function

Available since LÖVE 0.10.0
This variant is not supported in earlier versions.

Synopsis

love.mousereleased( x, y, button, istouch )

Arguments

number x
Mouse x position, in pixels.
number y
Mouse y position, in pixels.
number button
The button index that was released. 1 is the primary button (usually left-click), 2 is the secondary button, etc.
boolean istouch
True if the mouse button release originated from a touchscreen touch-release.

Returns

Nothing.

Function

Removed in LÖVE 0.10.0
This variant is not supported in that and later versions.

Synopsis

love.mousereleased( x, y, button )

Arguments

number x
Mouse x position.
number y
Mouse y position.
MouseConstant button
Mouse button released,except Mouse Wheel.

Returns

Nothing.

Examples

Position a string ("Text") wherever the user releases the primary mouse button.

function love.load()
   printx = 0
   printy = 0
end

function love.draw()
   love.graphics.print("Text", printx, printy)
end

function love.mousereleased(x, y, button)
   if button == 1 then
      printx = x
      printy = y
   end
end

See Also


Other Languages