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.
Build a new object to store collision test results.
Build a new object to store raycast test results.
The vertices of the polygon
Do 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.
The first polygon
The second polygon
If true, then edges that are touching each other, without the polygons actually overlapping, won't be considered in collision.
A collision result. collision
property is equal to true if polygons are overlapping. Do NOT keep a reference to this.
Copy a CollisionTestResult
into another one.
Use gdjs.Polygon.makeNewCollisionTestResult()
to build a new
destination before copying the existing source inside it.
Copy a RaycastTestResult
into another one.
Use gdjs.Polygon.makeNewRaycastTestResult()
to build a new
destination before copying the existing source inside it.
Do 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.
Generated using TypeDoc
Polygon represents a polygon which can be used to create collisions masks for RuntimeObject.