Mouse¶
Overview¶
The Mouse table contains functions which provide data belonging to the user's mouse input.
This data includes:
- Mouse availability (
falseon Mobile devices) - Mouse position
- TODO position with UI scaling applied
- TODO mouse button states
Info
The mouse position:
- is relative to the top-left of the game window, and
- updates only when the mouse is within the bounds of the game window.
Examples¶
if Mouse.IsAvailable() then
-- A Vector2 containing the mouse X & Y position
local xy = Mouse.GetPosition()
-- Or separately
local x = Mouse.GetX()
local y = Mouse.GetY()
end
Functions¶
IsAvailable¶
Returns whether mouse data is available on the current platform.
| Returns | Description |
|---|---|
| Boolean | Whether mouse data can be polled on the current platform.Returns false on Mobile devices, and true on all others. |
Example
GetPosition¶
Returns the current mouse X & Y position, if available.
| Returns | Description |
|---|---|
| Vector2? | The current mouse position.Returns nil on Mobile devices. |
GetX¶
Returns the current mouse X position, if available.
| Returns | Description |
|---|---|
| Integer? | The current X position of the mouse.Returns nil on Mobile devices. |
GetY¶
Returns the current mouse Y position, if available.
| Returns | Description |
|---|---|
| Integer? | The current Y position of the mouse.Returns nil on Mobile devices. |