The center of the polygon. This property is only valid after calling computeCenter, and remains valid until vertices are modified.
The edges of the polygon. This property is only valid after calling computeEdges, and remains valid until vertices are modified.
Static
makeBuild a new object to store collision test results.
Static
makeBuild a new object to store raycast test results.
The vertices of the polygon
Static
collisionDo a collision test between two polygons. Please note that polygons must convexes!
You can read the result but do not keep a reference to it as it's a static object
reused between function calls. If you need to keep the results, use copyCollisionTestResult
.
Uses Separating Axis Theorem .
Based on this
and this article.
A collision result. collision
property is equal to true if polygons are overlapping. Do NOT keep a reference to this.
Static
copyCopy a CollisionTestResult
into another one.
Use gdjs.Polygon.makeNewCollisionTestResult()
to build a new
destination before copying the existing source inside it.
Static
copyCopy a RaycastTestResult
into another one.
Use gdjs.Polygon.makeNewRaycastTestResult()
to build a new
destination before copying the existing source inside it.
Static
createStatic
crossStatic
distanceStatic
dotStatic
isStatic
normaliseStatic
projectStatic
raycastDo a raycast test. Please note that the polygon must be convex!
You can read the result but do not keep a reference to it as it's a static object
reused between function calls. If you need to keep the results, use copyRaycastTestResult
.
For some theory, check Find the Intersection Point of Two Line Segments.
The polygon to test
The raycast start point X
The raycast start point Y
The raycast end point X
The raycast end point Y
A raycast result with the contact points and distances. Do NOT keep a reference to this.
Polygon represents a polygon which can be used to create collisions masks for RuntimeObject.