com.badlogic.gdx.physics.box2d
Class PolygonShape

java.lang.Object
  extended by com.badlogic.gdx.physics.box2d.Shape
      extended by com.badlogic.gdx.physics.box2d.PolygonShape

public class PolygonShape
extends Shape


Nested Class Summary
 
Nested classes/interfaces inherited from class com.badlogic.gdx.physics.box2d.Shape
Shape.Type
 
Constructor Summary
PolygonShape()
          Constructs a new polygon
 
Method Summary
 Shape.Type getType()
          Get the type of this shape.
 void getVertex(int index, Vector2 vertex)
          Returns the vertex at the given position.
 int getVertexCount()
           
 void set(float[] vertices)
          Copy vertices from the given float array.
 void set(float[] vertices, int offset, int len)
          Copy vertices from the given float array, taking into account the offset and length.
 void set(Vector2[] vertices)
          Copy vertices.
 void setAsBox(float hx, float hy)
          Build vertices to represent an axis-aligned box.
 void setAsBox(float hx, float hy, Vector2 center, float angle)
          Build vertices to represent an oriented box.
 
Methods inherited from class com.badlogic.gdx.physics.box2d.Shape
dispose, getChildCount, getRadius, setRadius
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolygonShape

public PolygonShape()
Constructs a new polygon

Method Detail

getType

public Shape.Type getType()
Get the type of this shape. You can use this to down cast to the concrete shape.

Specified by:
getType in class Shape
Returns:
the shape type.

set

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.


set

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.


set

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.


setAsBox

public void setAsBox(float hx,
                     float hy)
Build vertices to represent an axis-aligned box.

Parameters:
hx - the half-width.
hy - the half-height.

setAsBox

public void setAsBox(float hx,
                     float hy,
                     Vector2 center,
                     float angle)
Build vertices to represent an oriented box.

Parameters:
hx - the half-width.
hy - the half-height.
center - the center of the box in local coordinates.
angle - the rotation in radians of the box in local coordinates.

getVertexCount

public int getVertexCount()
Returns:
the number of vertices

getVertex

public void getVertex(int index,
                      Vector2 vertex)
Returns the vertex at the given position.

Parameters:
index - the index of the vertex 0 <= index < getVertexCount( )
vertex - vertex


Copyright © 2013. All Rights Reserved.