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

public abstract Class Shape

extends Object
implements Disposable
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.utils.Disposable
Known Direct Subclasses
com.badlogic.gdx.physics.box2d.ChainShape, com.badlogic.gdx.physics.box2d.CircleShape, com.badlogic.gdx.physics.box2d.EdgeShape, com.badlogic.gdx.physics.box2d.PolygonShape
Imports
com.badlogic.gdx.utils.Disposable

A shape is used for collision detection. You can create a shape however you like. Shapes used for simulation in b2World are created automatically when a b2Fixture is created. Shapes may encapsulate a one or more child shapes.

Note

YOU NEED TO DISPOSE SHAPES YOU CREATED YOURSELF AFTER YOU NO LONGER USE THEM! E.g. after calling body.createFixture();

Author
mzechner

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Shape.Type

Enum describing the type of a shape

Field Summary

Modifier and TypeField and Description
protected long
addr

the address of the shape

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Needs to be called when the shape is no longer used, e.g. after a fixture was created based on the shape.

public int
getChildCount()

Get the number of child primitives.

public float
getRadius()

Returns the radius of this shape

public abstract Shape.Type

Returns:

the shape type.
getType
()

Get the type of this shape.

private native void
jniDispose(long addr)

private native int
jniGetChildCount(long addr)

private native float
jniGetRadius(long addr)

protected static native int
jniGetType(long addr)

private native void
jniSetRadius(long addr, float radius)

public void
setRadius(float radius)

Sets the radius of this shape

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addrback to summary
protected long addr

the address of the shape

Constructor Detail

Shapeback to summary
public Shape()

Method Detail

disposeback to summary
public void dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Needs to be called when the shape is no longer used, e.g. after a fixture was created based on the shape.

Annotations
@Override
getChildCountback to summary
public int getChildCount()

Get the number of child primitives.

getRadiusback to summary
public float getRadius()

Returns the radius of this shape

getTypeback to summary
public abstract Shape.Type getType()

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

Returns:Shape.Type

the shape type.

jniDisposeback to summary
private native void jniDispose(long addr)
jniGetChildCountback to summary
private native int jniGetChildCount(long addr)
jniGetRadiusback to summary
private native float jniGetRadius(long addr)
jniGetTypeback to summary
protected static native int jniGetType(long addr)
jniSetRadiusback to summary
private native void jniSetRadius(long addr, float radius)
setRadiusback to summary
public void setRadius(float radius)

Sets the radius of this shape

com.badlogic.gdx.physics.box2d back to summary

public final Enum Shape.Type

extends Enum<Shape.Type>
Class Inheritance

Enum describing the type of a shape
Author
mzechner

Field Summary

Modifier and TypeField and Description
public static final Shape.Type
public static final Shape.Type
public static final Shape.Type
public static final Shape.Type

Constructor Summary

AccessConstructor and Description
private
Type()

Method Summary

Modifier and TypeMethod and Description
public static Shape.Type
public static Shape.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

Chainback to summary
public static final Shape.Type Chain
Circleback to summary
public static final Shape.Type Circle
Edgeback to summary
public static final Shape.Type Edge
Polygonback to summary
public static final Shape.Type Polygon

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static Shape.Type valueOf(String name)
valuesback to summary
public static Shape.Type[] values()