Difference between revisions of "GetCursorPos"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "<b>History</b>: Available since <span style="color:green">v3.7</span> Stores the current position (absolute) of the mouse cursor into an x,y table which can be used in query ...")
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<b>History</b>: Available since <span style="color:green">v3.7</span>
+
==getCursorPos==
  
Stores the current position (absolute) of the mouse cursor into an x,y table which can be used in query to check if the current position is over an object/character or certain part of the scene etc.
+
<div class="command-min-version-info">Available since: <span class="command-min-version">v3.3</span></div>
  
Syntax:
+
<div class="command-doc">Returns the current absolute cursor position.</div>
<syntaxhighlight>
 
getCursorPos()
 
</syntaxhighlight>
 
  
Example:
+
Lua Syntax:
 +
<pre class="command-syntax">getCursorPos()</pre>
 +
===Arguments===
 +
===Flags===
 +
===Return Values===
 +
;pos
 +
:Table with x and y values containing cursor position.
 +
===Examples===
 +
Example 1:  
 
<syntaxhighlight>
 
<syntaxhighlight>
-- let's store the current position in a variable!
+
-- let's store the current position into a variable
local variableName = getCursorPos()
+
local curPos = getCursorPos()
  
-- let's check if the stored cursor position equals another x,y value!
+
-- let's check if the stored cursor position equals another x,y value
if variableName.x == 200 and variableName.y == 400 then
+
if curPos.x == 200 and curPos.y == 400 then
-- do some action!
+
  -- do some action
 
else
 
else
-- do some other action!
+
  -- do some other action
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 
<b><u>Arguments</u></b>
 
 
Flags: none
 
 
Return: Pos <br/>
 
Table containing x,y values of current mouse cursor position
 

Revision as of 21:27, 30 September 2014

getCursorPos

Available since: v3.3
Returns the current absolute cursor position.

Lua Syntax:

getCursorPos()

Arguments

Flags

Return Values

pos
Table with x and y values containing cursor position.

Examples

Example 1:

-- let's store the current position into a variable
local curPos = getCursorPos()

-- let's check if the stored cursor position equals another x,y value
if curPos.x == 200 and curPos.y == 400 then
  -- do some action
else
  -- do some other action
end