Difference between revisions of "love.mousemoved"

m
(See Also)
 
(3 intermediate revisions by 3 users not shown)
Line 2: Line 2:
 
Callback function triggered when the mouse is moved.
 
Callback function triggered when the mouse is moved.
 
== Function ==
 
== Function ==
{{newin|[[0.10.0]]|100|type=variant}}
 
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
Line 12: Line 11:
 
{{param|number|dx|The amount moved along the x-axis since the last time love.mousemoved was called.}}
 
{{param|number|dx|The amount moved along the x-axis since the last time love.mousemoved was called.}}
 
{{param|number|dy|The amount moved along the y-axis since the last time love.mousemoved was called.}}
 
{{param|number|dy|The amount moved along the y-axis since the last time love.mousemoved was called.}}
 +
{{New feature|0.10.0|
 
{{param|boolean|istouch|True if the mouse button press originated from a touchscreen touch-press.}}
 
{{param|boolean|istouch|True if the mouse button press originated from a touchscreen touch-press.}}
 +
|100}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
== Function ==
+
== Notes ==
{{oldin|[[0.10.0]]|100|type=variant}}
+
If [[love.mouse.setRelativeMode|Relative Mode]] is enabled for the mouse, the '''dx''' and '''dy''' arguments of this callback will update but '''x''' and '''y''' are not guaranteed to.
=== Synopsis ===
+
 
 +
 
 +
== Examples ==
 +
Position a string ("Text") wherever the mouse, also the delta x and y.
 
<source lang="lua">
 
<source lang="lua">
love.mousemoved( x, y, dx, dy )
+
function love.load()
 +
printx = 0
 +
printy = 0
 +
printdx = 0
 +
printdy = 0
 +
end
 +
 
 +
function love.draw()
 +
love.graphics.print("Text", printx, printy)
 +
love.graphics.print('dx: '..printdx .. ' dy: '.. printdy, 0, 0)
 +
end
 +
 
 +
function love.mousemoved( x, y, dx, dy, istouch )
 +
printx = x
 +
printy = y
 +
printdx = dx
 +
printdy = dy
 +
end
 
</source>
 
</source>
=== Arguments ===
+
 
{{param|number|x|The mouse position on the x-axis.}}
 
{{param|number|y|The mouse position on the y-axis.}}
 
{{param|number|dx|The amount moved along the x-axis since the last time love.mousemoved was called.}}
 
{{param|number|dy|The amount moved along the y-axis since the last time love.mousemoved was called.}}
 
=== Returns ===
 
Nothing.
 
== Notes ==
 
If [[love.mouse.setRelativeMode|Relative Mode]] is enabled for the mouse, the '''dx''' and '''dy''' arguments of this callback will update but '''x''' and '''y''' are not guaranteed to.
 
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]
 +
* [[love.mouse]]
 
* [[love.mousepressed]]
 
* [[love.mousepressed]]
 
* [[love.mousereleased]]
 
* [[love.mousereleased]]
Line 38: Line 52:
 
* [[love.mouse.setRelativeMode]]
 
* [[love.mouse.setRelativeMode]]
 
* [[love.mouse.getRelativeMode]]
 
* [[love.mouse.getRelativeMode]]
 +
* [[love.mouse.isDown]]
 
[[Category:Callbacks]]
 
[[Category:Callbacks]]
 
{{#set:Description=Callback function triggered when the mouse is moved.}}
 
{{#set:Description=Callback function triggered when the mouse is moved.}}
{{#set:Subcategory=General}}
+
{{#set:Subcategory=Mouse}}
 +
 
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.mousemoved}}
 
{{i18n|love.mousemoved}}

Latest revision as of 15:26, 2 February 2023

Available since LÖVE 0.9.2
This function is not supported in earlier versions.

Callback function triggered when the mouse is moved.

Function

Synopsis

love.mousemoved( x, y, dx, dy, istouch )

Arguments

number x
The mouse position on the x-axis.
number y
The mouse position on the y-axis.
number dx
The amount moved along the x-axis since the last time love.mousemoved was called.
number dy
The amount moved along the y-axis since the last time love.mousemoved was called.
Available since LÖVE 0.10.0
boolean istouch
True if the mouse button press originated from a touchscreen touch-press.

Returns

Nothing.

Notes

If Relative Mode is enabled for the mouse, the dx and dy arguments of this callback will update but x and y are not guaranteed to.


Examples

Position a string ("Text") wherever the mouse, also the delta x and y.

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

function love.draw()
	love.graphics.print("Text", printx, printy)
	love.graphics.print('dx: '..printdx .. ' dy: '.. printdy, 0, 0)
end

function love.mousemoved( x, y, dx, dy, istouch )
	printx = x
	printy = y
	printdx = dx
	printdy = dy
end

See Also


Other Languages