Polygon

nape.phys.InteractorShapenape.shape.Polygon (final class)

Polygon subtype of Shape.

Can be used to simulate any convex polygon.

Static Members

nape
rect(x: Float, y: Float, width: Float, height: Float, ?weak: Bool = false): Array<nape.geom.Vec2>

Construct a polygon representing a rectangle.

For a dynamic object, you may consider use of the box method instead as dynamic bodies will only respond as expected if their centre of mass is equal to the origin.

The generate polygon will have coordinates equal to:

(x, y) -> (x + width, y + height)

Negative values of width/height are permitted so that the given x/y values may not necessarigly be the top-left corner of rectangle.

Name Type Default Description
x Float The x coordinate of rectangle.
y Float The y coordinate of rectangle.
width Float The width of the ractangle. This value may be negative.
height Float The height of the rectangle This value may be negative.
weak Bool false If true, the generated list of vertices will be allocated as weak Vec2s so that when this list is passed to a Nape function these Vec2s will be automatically sent back to object pool. (default false)
Returns Description
Array<nape.geom.Vec2> An array of Vec2 representing the given rectangle.

nape
box(width: Float, height: Float, ?weak: Bool = false): Array<nape.geom.Vec2>

Construct a polygon representing an origin centred box.

This method is equivalent to calling: Polygon.rect(-width/2,-height/2,width,height)

Name Type Default Description
width Float The width of the box (This value may be negative but will make no difference).
height Float The height of the box (This value may be negative but will make no difference).
weak Bool false If true, the generated list of vertices will be allocated as weak Vec2s so that when this list is passed to a Nape function these Vec2s will be automatically sent back to object pool. (default false)
Returns Description
Array<nape.geom.Vec2> An array of Vec2 representing the given box.

nape
regular(xRadius: Float, yRadius: Float, edgeCount: Int, ?angleOffset: Float = 0.0, ?weak: Bool = false): Array<nape.geom.Vec2>

Construct a regular polygon centred at origin.

Vertices are created at positions on the edge of an ellipsoid of given radii, when radii are not equal the vertices will not have an equal angle between them; it will be as though an actual regular polygon were created, and then squashed to conform to the input radii.

Name Type Default Description
xRadius Float The x radius of polygon before angleOffset rotation.
yRadius Float The y radius of polygon before angleOffset rotation.
edgeCount Int The number of edges/vertices in polygon.
angleOffset Float 0.0 The clockwise angular offset to generate vertices at in radians. (default 0.0)
weak Bool false If true, the generated list of vertices will be allocated as weak Vec2s so that when this list is passed to a Nape function these Vec2s will be automatically sent back to object pool. (default false)
Returns Description
Array<nape.geom.Vec2> An array of Vec2 representing the polygon.

Instance Members

nape
zpp_inner_zn: zpp_nape.shape.ZPP_Polygon

@private


nape
localVerts: nape.geom.Vec2List

Local coordinates of vertices.

This list can be modified, but modifications to a Polygon that is part of a static Body inside of a Space will given an error in debug builds.


nape
worldVerts: nape.geom.Vec2List

World coordinates of vertices.

This list can be accessed, but any queries of values will result in an error in debug builds unless this Polygon is part of a Body.

This list is immutable.


nape
edges: EdgeList

Set of edges on polygon.

This list is immutable.


nape
validity(): ValidationResult

Determine validity of polygon for use in a Nape simulation.

Returns
ValidationResult

nape
new(localVerts: Dynamic, ?material: nape.phys.Material = null, ?filter: nape.dynamics.InteractionFilter = null): Void

Construct a new Polygon.

The localVerts parameter is typed Dynamic and may be one of: Array<Vec2>, flash.Vector<Vec2>, Vec2List, GeomPoly

Name Type Default Description
localVerts Dynamic The local vertices of polygon.
material nape.phys.Material null The material for this polygon. (default new Material())
filter nape.dynamics.InteractionFilter null The interaction filter for this polygon. (default new InteractionFilter())

Private Members

Metadata

Name Parameters
:final -