Static methods

@:value({ scale_y : 1, scale_x : 1, rotation : 0, radius : 1, sides : 3, y : 0, x : 0 })staticinlineget(x:Float = 0, y:Float = 0, sides:Int = 3, radius:Float = 1, rotation:Float = 0, scale_x:Float = 1, scale_y:Float = 1):Polygon

Gets a Polygon from the pool, or creates a new one if none are available. Call put() on the Polygon to place it back in the pool.

Parameters:

x
y
sides
radius
rotation

Returns:

Polygon

staticinlineget_from_rect(rect:Rect):Polygon

Gets a Polygon from the pool, or creates a new one if none are available. Call put() on the Polygon to place it back in the pool.

Parameters:

rect

Returns:

Polygon return _pool.get().set_from_rect(rect)

@:value({ scale_y : 1, scale_x : 1, rotation : 0, y : 0, x : 0 })staticinlineget_from_vertices(x:Float = 0, y:Float = 0, rotation:Float = 0, ?vertices:Array<Vector2>, scale_x:Float = 1, scale_y:Float = 1):Polygon

Gets a Polygon from the pool, or creates a new one if none are available. Call put() on the Polygon to place it back in the pool.

Parameters:

x
y
rotation
vertices

Returns:

Polygon

Variables

read onlycount:Int

The amount of vertices in the Polygon.

read onlynormals:Array<Vector2>

The Polygon's computed normals.

This Array represents a cache'd value, so changes to this Array will be overwritten. Use set_vertice() or set_vertices() to edit this Polygon's normals.

@:value(false)read onlypooled:Bool = false

read onlyvertices:Array<Vector2>

The Polygon's vertices adjusted for it's rotation.

This Array represents a cache'd value, so changes to this Array will be overwritten. Use set_vertice() or set_vertices() to edit this Polygon's vertices.

Methods

inlineload(polygon:Polygon):Polygon

@:value({ scale_y : 1, scale_x : 1, rotation : 0, y : 0, x : 0 })inlineset(x:Float = 0, y:Float = 0, rotation:Float = 0, ?vertices:Array<Vector2>, scale_x:Float = 1, scale_y:Float = 1):Polygon

@:value({ y : 0, x : 0 })inlineset_vertice(index:Int, x:Float = 0, y:Float = 0):Void

Sets the vertice at the desired index.

Parameters:

index
x
null

y

inlineset_vertices(?vertices:Array<Vector2>, ?count:Int):Void

inlineto_rect():Rect

Inherited Variables

Defined by Shape

read onlybottom:Float

The Lower Bounds of the Shape.

collided:Bool

Flag to determine if the Shape has collided in the last World step. Used Internally for Debugging.

read onlyleft:Float

The Left Bounds of the Shape.

local_x:Float

The Shape's position on the X axis. For Rects, Circles, and simple Polygons, this position is based on the center of the Shape.

If added to a Body, this value is treated as an offset to the Body's X position.

local_y:Float

The Shape's position on the Y axis. For Rects, Circles, and simple Polygons, this position is based on the center of the Shape.

If added to a Body, this value is treated as an offset to the Body's Y position.

read onlyright:Float

The Right Bounds of the Shape.

rotation:Float

The Shape's angular rotation.

If added to a Body, this value is relative to the Body's rotation. To get the Shape's local rotation in this case, use local_rotation.

@:value(true)solid:Bool = true

Flag to set whether the Shape collides with other Shapes.

If false, this Shape's Body will not have its position or velocity affected by other Bodies, but it will still call collision callbacks

read onlytop:Float

The Upper Bounds of the Shape.

@:value(new Transform())transform:Transform = new Transform()

type:ShapeType

Enum value determining what shape this Object is (Rect, Circle, Polygon).

x:Float

The Shape's position on the X axis. For Rects, Circles, and simple Polygons, this position is based on the center of the Shape.

If added to a Body, this value is relative to the Body's X position. To get the Shape's local X position in this case, use local_x.

y:Float

The Shape's position on the Y axis. For Rects, Circles, and simple Polygons, this position is based on the center of the Shape.

If added to a Body, this value is relative to the Body's Y position. To get the Shape's local Y position in this case, use local_y.

Inherited Methods

Defined by Shape

inlineget_position():Vector2

Gets the Shape's position on the X and Y axis as a Vector2.

inlineset_position(position:Vector2):Void