APIdia Launch Partner
Top Fields Constructors Methods
com.badlogic.gdx.physics.box2d

public Class PolygonShape

extends Shape
Class Inheritance
Imports
com.badlogic.gdx.math.Vector2

Field Summary

Modifier and TypeField and Description
private static float[]
Inherited from com.badlogic.gdx.physics.box2d.Shape:
addr

Constructor Summary

AccessConstructor and Description
public
PolygonShape()

Constructs a new polygon

protected
PolygonShape(long addr)

Method Summary

Modifier and TypeMethod and Description
public Shape.Type
getType()

Implements abstract com.badlogic.gdx.physics.box2d.Shape.getType.

Get the type of this shape.

public void
getVertex(int
the index of the vertex 0 <= index < getVertexCount( )
index
,
Vector2
vertex
vertex
)

Returns the vertex at the given position.

public int
getVertexCount()

Returns: the number of vertices

private native void
jniGetVertex(long addr, int index, float[] verts)

private native int
jniGetVertexCount(long addr)

private native void
jniSet(long addr, float[] verts, int offset, int len)

private native void
jniSetAsBox(long addr, float hx, float hy)

private native void
jniSetAsBox(long addr, float hx, float hy, float centerX, float centerY, float angle)

private native long
public void
set(Vector2[] vertices)

Copy vertices.

public void
set(float[] vertices)

Copy vertices from the given float array.

public void
set(float[] vertices, int offset, int len)

Copy vertices from the given float array, taking into account the offset and length.

public void
setAsBox(float
the half-width.
hx
,
float
the half-height.
hy
)

Build vertices to represent an axis-aligned box.

public void
setAsBox(float
the half-width.
hx
,
float
the half-height.
hy
,
Vector2
the center of the box in local coordinates.
center
,
float
the rotation in radians of the box in local coordinates.
angle
)

Build vertices to represent an oriented box.

Inherited from com.badlogic.gdx.physics.box2d.Shape:
disposegetChildCountgetRadiusjniGetTypesetRadius

Field Detail

vertsback to summary
private static float[] verts

Constructor Detail

PolygonShapeback to summary
public PolygonShape()

Constructs a new polygon

PolygonShapeback to summary
protected PolygonShape(long addr)

Method Detail

getTypeback to summary
public Shape.Type getType()

Implements abstract com.badlogic.gdx.physics.box2d.Shape.getType.

Doc from com.badlogic.gdx.physics.box2d.Shape.getType.

Get the type of this shape. You can use this to down cast to the concrete shape.

Annotations
@Override
getVertexback to summary
public void getVertex(int index, Vector2 vertex)

Returns the vertex at the given position.

Parameters
index:int

the index of the vertex 0 <= index < getVertexCount( )

vertex:Vector2

vertex

getVertexCountback to summary
public int getVertexCount()
Returns:int

the number of vertices

jniGetVertexback to summary
private native void jniGetVertex(long addr, int index, float[] verts)
jniGetVertexCountback to summary
private native int jniGetVertexCount(long addr)
jniSetback to summary
private native void jniSet(long addr, float[] verts, int offset, int len)
jniSetAsBoxback to summary
private native void jniSetAsBox(long addr, float hx, float hy)
jniSetAsBoxback to summary
private native void jniSetAsBox(long addr, float hx, float hy, float centerX, float centerY, float angle)
newPolygonShapeback to summary
private native long newPolygonShape()
setback to summary
public void set(Vector2[] vertices)

Copy vertices. This assumes the vertices define a convex polygon. It is assumed that the exterior is the the right of each edge.

setback to summary
public void set(float[] vertices)

Copy vertices from the given float array. It is assumed the vertices are in x,y order and define a convex polygon. It is assumed that the exterior is the the right of each edge.

setback to summary
public void set(float[] vertices, int offset, int len)

Copy vertices from the given float array, taking into account the offset and length. It is assumed the vertices are in x,y order and define a convex polygon. It is assumed that the exterior is the the right of each edge.

setAsBoxback to summary
public void setAsBox(float hx, float hy)

Build vertices to represent an axis-aligned box.

Parameters
hx:float

the half-width.

hy:float

the half-height.

setAsBoxback to summary
public void setAsBox(float hx, float hy, Vector2 center, float angle)

Build vertices to represent an oriented box.

Parameters
hx:float

the half-width.

hy:float

the half-height.

center:Vector2

the center of the box in local coordinates.

angle:float

the rotation in radians of the box in local coordinates.