Global Command: isPointInsidePolygon

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Redirected from IsPointInsidePolygon)

Test if a point lies inside a polygon.


Syntax

isPointInsidePolygon(point, polygon)


Parameters

Parameter Type/Structure Description
point table x (int) Horizontal position (X coordinate) Pass the point as a Visionaire "t_point" field: an associative array containing the elements x and y.
y (int) Vertical position (Y coordinate)
polygon table of tables {{x=int,y=int},...} A single polygon, consisting of a table of Visionaire "t_point" fields. Bear in mind that a field containing multiple polygons (e. g. a way border or object polygon) must be split into single polygons and tested separately. Visionaire uses {-10000,-10000} points ("DIVIDING_POINT" constant) to separate individual polygons from each other in the data structure.


Return values

Type Description
boolean True if the point lies within the polygon.


Examples

Example 1: Test if the current position of an active "cloud" animation is inside the polygon of a "window" object on the current scene and store the result in a global variable.

local cloudAnim = ActiveAnimations["cloud"]
local windowPolygon = game.CurrentScene.Objects["window"].Polygon

cloudVisible = isPointInsidePolygon(cloudAnim.CurrentPosition, windowPolygon)