Fork me on GitHub
View source

package com.haxepunk.masks

class Polygon


extends Hitbox

Uses polygonal structure to check for collisions.

Static functions

View source

static createFromArray (points : Array<Float>) : Polygon

Creates a polygon from an array were even numbers are x and odd are y


Parameters:
points   

Array containing the polygon's points.


Returns:

The polygon

View source

static createPolygon (sides : Int = 3, radius : Float = 100, angle : Float = 0) : Polygon

Creates a regular polygon (edges of same length).


Parameters:
sides   

The number of sides in the polygon.

radius   

The distance that the vertices are at.

angle   

How much the polygon is rotated (in degrees).


Returns:

The polygon

Constructor

View source

new (points : Array<Vector>, origin : Point) : Void

Constructor.


Parameters:
points   

An array of coordinates that define the polygon (must have at least 3).

origin   

Pivot point for rotations.

Variables

angle : Float

Rotation angle (in degrees) of the polygon (rotates around origin point).

read only maxX : Int

Right x bounding box position.

read only maxY : Int

Bottom y bounding box position.

read only minX : Int

Left x bounding box position.

read only minY : Int

Top y bounding box position.

origin : Point

The polygon rotates around this point when the angle is set.

points : Array<Vector>

The points representing the polygon.

If you need to set a point yourself instead of passing in a new Array you need to call update() to make sure the axes update as well.