Difference between revisions of "Global Command: setCursorPos"
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "<div class="toccolours mw-collapsible mw-collapsed tbl-ds"> <span class="bold">Function History</span> <div class="mw-collapsible-content"> <div class="alt-bg">Available since...") |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | Sets the mouse cursor to the {x,y} position provided. | |
− | |||
− | |||
− | |||
− | |||
+ | Note that the coordinates must be provided in relation to the screen instead of in relation to the scene. This difference matters if your scene is larger than your screen resolution and thus scrollable. | ||
− | + | {| class="ts" | |
+ | |- | ||
+ | | style="width:15%" | Related functions | ||
+ | | [[Global Command: getCursorPos|getCursorPos]] | ||
+ | |} | ||
− | Syntax | + | == Syntax == |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
setCursorPos(pos) | setCursorPos(pos) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | == Parameters == | |
− | |||
− | |||
− | |||
− | + | {| class="ts" | |
− | + | |- | |
− | + | ! style="width:15%" | Parameter | |
− | + | ! style="width:15%" colspan="2" | Type/Structure | |
− | + | ! colspan="2" | Description | |
− | + | |- | |
− | + | | rowspan="2" | pos | |
− | + | | rowspan="2" | table | |
− | + | | x (int) | |
− | + | | style="width:25%" | Horizontal position (X coordinate) | |
− | + | | rowspan="2" | Pass the position where the mouse cursor should be set to as a Visionaire "t_point" field: an associative array containing the elements '''x''' and '''y'''. | |
− | + | |- | |
− | + | | y (int) | |
+ | | Vertical position (Y coordinate) | ||
+ | |} | ||
− | + | == Return values == | |
none | none | ||
− | + | == Examples == | |
− | + | '''Example 1:''' Set the mouse cursor to position {240,480} of the screen. | |
+ | <syntaxhighlight lang="lua"> | ||
+ | -- Pass a "t_point" table to the function | ||
+ | setCursorPos({x=240,y=480}) | ||
− | + | -- You could use a variable instead | |
− | { | + | local cPos = {x=240,y=480} |
− | + | setCursorPos(cPos) | |
− | + | </syntaxhighlight> | |
− | + | {{toc}} |
Latest revision as of 16:31, 2 May 2023
Sets the mouse cursor to the {x,y} position provided.
Note that the coordinates must be provided in relation to the screen instead of in relation to the scene. This difference matters if your scene is larger than your screen resolution and thus scrollable.
Related functions | getCursorPos |
Syntax
setCursorPos(pos)
Parameters
Parameter | Type/Structure | Description | ||
---|---|---|---|---|
pos | table | x (int) | Horizontal position (X coordinate) | Pass the position where the mouse cursor should be set to as a Visionaire "t_point" field: an associative array containing the elements x and y. |
y (int) | Vertical position (Y coordinate) |
Return values
none
Examples
Example 1: Set the mouse cursor to position {240,480} of the screen.
-- Pass a "t_point" table to the function
setCursorPos({x=240,y=480})
-- You could use a variable instead
local cPos = {x=240,y=480}
setCursorPos(cPos)