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

public Class Body

extends Object
Class Inheritance
Imports
com.badlogic.gdx.math.Vector2, com.badlogic.gdx.physics.box2d.BodyDef.BodyType, com.badlogic.gdx.utils.Array, .BufferUtils, java.nio.ByteBuffer, .ByteOrder

A rigid body. These are created via World.CreateBody.
Author
mzechner

Field Summary

Modifier and TypeField and Description
protected long
addr

the address of the body

private Array<Fixture>
fixtures

Fixtures of this body

protected Array<JointEdge>
joints

Joints of this body

private final Vector2
public final Vector2
public final Vector2
private final Vector2
private final Vector2
public final Vector2
public final Vector2
private final MassData
private final Vector2
private final float[]
tmp

temporary float array

private final ByteBuffer
tmpBuff

temporary ByteBuffer

private final long
private final Transform
private Object
userData

user data

private final World
world

World

private final Vector2
private final Vector2

Constructor Summary

AccessConstructor and Description
protected
Body(World
the world
world
,
long
the address
addr
)

Constructs a new body with the given address

Method Summary

Modifier and TypeMethod and Description
public void
applyAngularImpulse(float
the angular impulse in units of kg*m*m/s
impulse
,
boolean wake)

Apply an angular impulse.

public void
applyForce(Vector2
the world force vector, usually in Newtons (N).
force
,
Vector2
the world position of the point of application.
point
,
boolean
up the body
wake
)

Apply a force at a world point.

public void
applyForce(float
the world force vector on x, usually in Newtons (N).
forceX
,
float
the world force vector on y, usually in Newtons (N).
forceY
,
float
the world position of the point of application on x.
pointX
,
float
the world position of the point of application on y.
pointY
,
boolean
up the body
wake
)

Apply a force at a world point.

public void
applyForceToCenter(Vector2
the world force vector, usually in Newtons (N).
force
,
boolean wake)

Apply a force to the center of mass.

public void
applyForceToCenter(float
the world force vector, usually in Newtons (N).
forceX
,
float
the world force vector, usually in Newtons (N).
forceY
,
boolean wake)

Apply a force to the center of mass.

public void
applyLinearImpulse(Vector2
the world impulse vector, usually in N-seconds or kg-m/s.
impulse
,
Vector2
the world position of the point of application.
point
,
boolean
up the body
wake
)

Apply an impulse at a point.

public void
applyLinearImpulse(float
the world impulse vector on the x-axis, usually in N-seconds or kg-m/s.
impulseX
,
float
the world impulse vector on the y-axis, usually in N-seconds or kg-m/s.
impulseY
,
float
the world position of the point of application on the x-axis.
pointX
,
float
the world position of the point of application on the y-axis.
pointY
,
boolean
up the body
wake
)

Apply an impulse at a point.

public void
applyTorque(float
about the z-axis (out of the screen), usually in N-m.
torque
,
boolean
up the body
wake
)

Apply a torque.

public Fixture
createFixture(FixtureDef
the fixture definition.
def
)

Creates a fixture and attach it to this body.

public Fixture
createFixture(Shape
the shape to be cloned.
shape
,
float
the shape density (set to zero for static bodies).
density
)

Creates a fixture from a shape and attach it to this body.

public void
destroyFixture(Fixture
the fixture to be removed.
fixture
)

Destroy a fixture.

public float

Returns:

the current world rotation angle in radians.
getAngle
()

Get the angle in radians.

public float
getAngularDamping()

Get the angular damping of the body.

public float
getAngularVelocity()

Get the angular velocity.

public Array<Fixture>
getFixtureList()

Get the list of all fixtures attached to this body.

public float
getGravityScale()

Returns: Get the gravity scale of the body.

public float

Returns:

the rotational inertia, usually in kg-m^2.
getInertia
()

Get the rotational inertia of the body about the local origin.

public Array<JointEdge>
getJointList()

Get the list of all joints attached to this body.

public float
getLinearDamping()

Get the linear damping of the body.

public Vector2
getLinearVelocity()

Get the linear velocity of the center of mass.

public Vector2

Returns:

the world velocity of a point.
getLinearVelocityFromLocalPoint
(Vector2
a point in local coordinates.
localPoint
)

Get the world velocity of a local point.

public Vector2

Returns:

the world velocity of a point.
getLinearVelocityFromWorldPoint
(Vector2
a point in world coordinates.
worldPoint
)

Get the world linear velocity of a world point attached to this body.

public Vector2
getLocalCenter()

Get the local position of the center of mass.

public Vector2

Returns:

the corresponding local point relative to the body's origin.
getLocalPoint
(Vector2
a point in world coordinates.
worldPoint
)

Gets a local point relative to the body's origin given a world point.

public Vector2

Returns:

the corresponding local vector.
getLocalVector
(Vector2
a vector in world coordinates.
worldVector
)

Gets a local vector given a world vector.

public float

Returns:

the mass, usually in kilograms (kg).
getMass
()

Get the total mass of the body.

public MassData

Returns:

a struct containing the mass, inertia and center of the body.
getMassData
()

Get the mass data of the body.

public Vector2

Returns:

the world position of the body's origin.
getPosition
()

Get the world body origin position.

public Transform
getTransform()

Get the body transform for the body's origin.

public BodyDef.BodyType
getType()

Get the type of this body.

public Object
getUserData()

Get the user data

public World
getWorld()

Get the parent world of this body.

public Vector2
getWorldCenter()

Get the world position of the center of mass.

public Vector2

Returns:

the same point expressed in world coordinates.
getWorldPoint
(Vector2
a point on the body measured relative the the body's origin.
localPoint
)

Get the world coordinates of a point given the local coordinates.

public Vector2

Returns:

the same vector expressed in world coordinates.
getWorldVector
(Vector2
a vector fixed in the body.
localVector
)

Get the world coordinates of a vector given the local coordinates.

public boolean
isActive()

Get the active state of the body.

public boolean

Returns:

true if the body is not sleeping.
isAwake
()

Get the sleeping state of this body.

public boolean
isBullet()

Is this body treated like a bullet for continuous collision detection?

public boolean
isFixedRotation()

Does this body have fixed rotation?

public boolean
isSleepingAllowed()

Is this body allowed to sleep

private native void
jniApplyAngularImpulse(long addr, float impulse, boolean wake)

private native void
jniApplyForce(long addr, float forceX, float forceY, float pointX, float pointY, boolean wake)

private native void
jniApplyForceToCenter(long addr, float forceX, float forceY, boolean wake)

private native void
jniApplyLinearImpulse(long addr, float impulseX, float impulseY, float pointX, float pointY, boolean wake)

private native void
jniApplyTorque(long addr, float torque, boolean wake)

private native long
jniCreateFixture(long addr, long shapeAddr, float friction, float restitution, float density, boolean isSensor, short filterCategoryBits, short filterMaskBits, short filterGroupIndex)

private native long
jniCreateFixture(long addr, long shapeAddr, float density)

private native float
jniGetAngle(long addr)

private native float
private native float
private native float
jniGetGravityScale(long addr)

private native float
jniGetInertia(long addr)

private native float
private native void
jniGetLinearVelocity(long addr, long linearVelocityAddr)

private native void
jniGetLinearVelocityFromLocalPoint(long addr, float localPointX, float localPointY, long linVelLocAddr)

private native void
jniGetLinearVelocityFromWorldPoint(long addr, float worldPointX, float worldPointY, long linVelWorldAddr)

private native void
jniGetLocalCenter(long addr, long localCenterAddr)

private native void
jniGetLocalPoint(long addr, float worldPointX, float worldPointY, long localPointAddr)

private native void
jniGetLocalVector(long addr, float worldVectorX, float worldVectorY, long worldVectorAddr)

private native float
jniGetMass(long addr)

private native void
jniGetMassData(long addr, float[] massData)

private native void
jniGetPosition(long addr, long positionAddr)

private native void
jniGetTransform(long addr, float[] vals)

private native int
jniGetType(long addr)

private native void
jniGetWorldCenter(long addr, long worldCenterAddr)

private native void
jniGetWorldPoint(long addr, float localPointX, float localPointY, long worldPointAddr)

private native void
jniGetWorldVector(long addr, float localVectorX, float localVectorY, long worldVectorAddr)

private native boolean
jniIsActive(long addr)

private native boolean
jniIsAwake(long addr)

private native boolean
jniIsBullet(long addr)

private native boolean
jniIsFixedRotation(long addr)

private native boolean
private native void
jniResetMassData(long addr)

private native void
jniSetActive(long addr, boolean flag)

private native void
jniSetAngularDamping(long addr, float angularDamping)

private native void
jniSetAngularVelocity(long addr, float omega)

private native void
jniSetAwake(long addr, boolean flag)

private native void
jniSetBullet(long addr, boolean flag)

private native void
jniSetFixedRotation(long addr, boolean flag)

private native void
jniSetGravityScale(long addr, float scale)

private native void
jniSetLinearDamping(long addr, float linearDamping)

private native void
jniSetLinearVelocity(long addr, float x, float y)

private native void
jniSetMassData(long addr, float mass, float centerX, float centerY, float I)

private native void
jniSetSleepingAllowed(long addr, boolean flag)

private native void
jniSetTransform(long addr, float positionX, float positionY, float angle)

private native void
jniSetType(long addr, int type)

protected void
reset(long addr)

Resets this body after fetching it from the World#freeBodies Pool.

public void
resetMassData()

This resets the mass properties to the sum of the mass properties of the fixtures.

public void
setActive(boolean flag)

Set the active state of the body.

public void
setAngularDamping(float angularDamping)

Set the angular damping of the body.

public void
setAngularVelocity(float omega)

Set the angular velocity.

public void
setAwake(boolean
set to true to wake the body, false to put it to sleep.
flag
)

Set the sleep state of the body.

public void
setBullet(boolean flag)

Should this body be treated like a bullet for continuous collision detection?

public void
setFixedRotation(boolean flag)

Set this body to have fixed rotation.

public void
setGravityScale(float scale)

Sets the gravity scale of the body

public void
setLinearDamping(float linearDamping)

Set the linear damping of the body.

public void
setLinearVelocity(Vector2 v)

Set the linear velocity of the center of mass.

public void
setLinearVelocity(float vX, float vY)

Set the linear velocity of the center of mass.

public void
setMassData(MassData
the mass properties.
data
)

Set the mass properties to override the mass properties of the fixtures.

public void
setSleepingAllowed(boolean flag)

You can disable sleeping on this body.

public void
setTransform(Vector2
the world position of the body's local origin.
position
,
float
the world rotation in radians.
angle
)

Set the position of the body's origin and rotation.

public void
setTransform(float
the world position on the x-axis
x
,
float
the world position on the y-axis
y
,
float
the world rotation in radians.
angle
)

Set the position of the body's origin and rotation.

public void
setType(BodyDef.BodyType type)

Set the type of this body.

public void
setUserData(Object userData)

Set the user data

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addrback to summary
protected long addr

the address of the body

fixturesback to summary
private Array<Fixture> fixtures

Fixtures of this body

jointsback to summary
protected Array<JointEdge> joints

Joints of this body

linearVelocityback to summary
private final Vector2 linearVelocity
linVelLocback to summary
public final Vector2 linVelLoc
linVelWorldback to summary
public final Vector2 linVelWorld
localCenterback to summary
private final Vector2 localCenter
localPointback to summary
private final Vector2 localPoint
localPoint2back to summary
public final Vector2 localPoint2
localVectorback to summary
public final Vector2 localVector
massDataback to summary
private final MassData massData
positionback to summary
private final Vector2 position
tmpback to summary
private final float[] tmp

temporary float array

tmpBuffback to summary
private final ByteBuffer tmpBuff

temporary ByteBuffer

tmpBuffAddressback to summary
private final long tmpBuffAddress
transformback to summary
private final Transform transform
userDataback to summary
private Object userData

user data

worldback to summary
private final World world

World

worldCenterback to summary
private final Vector2 worldCenter
worldVectorback to summary
private final Vector2 worldVector

Constructor Detail

Bodyback to summary
protected Body(World world, long addr)

Constructs a new body with the given address

Parameters
world:World

the world

addr:long

the address

Method Detail

applyAngularImpulseback to summary
public void applyAngularImpulse(float impulse, boolean wake)

Apply an angular impulse.

Parameters
impulse:float

the angular impulse in units of kg*m*m/s

applyForceback to summary
public void applyForce(Vector2 force, Vector2 point, boolean wake)

Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.

Parameters
force:Vector2

the world force vector, usually in Newtons (N).

point:Vector2

the world position of the point of application.

wake:boolean

up the body

applyForceback to summary
public void applyForce(float forceX, float forceY, float pointX, float pointY, boolean wake)

Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.

Parameters
forceX:float

the world force vector on x, usually in Newtons (N).

forceY:float

the world force vector on y, usually in Newtons (N).

pointX:float

the world position of the point of application on x.

pointY:float

the world position of the point of application on y.

wake:boolean

up the body

applyForceToCenterback to summary
public void applyForceToCenter(Vector2 force, boolean wake)

Apply a force to the center of mass. This wakes up the body.

Parameters
force:Vector2

the world force vector, usually in Newtons (N).

applyForceToCenterback to summary
public void applyForceToCenter(float forceX, float forceY, boolean wake)

Apply a force to the center of mass. This wakes up the body.

Parameters
forceX:float

the world force vector, usually in Newtons (N).

forceY:float

the world force vector, usually in Newtons (N).

applyLinearImpulseback to summary
public void applyLinearImpulse(Vector2 impulse, Vector2 point, boolean wake)

Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.

Parameters
impulse:Vector2

the world impulse vector, usually in N-seconds or kg-m/s.

point:Vector2

the world position of the point of application.

wake:boolean

up the body

applyLinearImpulseback to summary
public void applyLinearImpulse(float impulseX, float impulseY, float pointX, float pointY, boolean wake)

Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.

Parameters
impulseX:float

the world impulse vector on the x-axis, usually in N-seconds or kg-m/s.

impulseY:float

the world impulse vector on the y-axis, usually in N-seconds or kg-m/s.

pointX:float

the world position of the point of application on the x-axis.

pointY:float

the world position of the point of application on the y-axis.

wake:boolean

up the body

applyTorqueback to summary
public void applyTorque(float torque, boolean wake)

Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.

Parameters
torque:float

about the z-axis (out of the screen), usually in N-m.

wake:boolean

up the body

createFixtureback to summary
public Fixture createFixture(FixtureDef def)

Creates a fixture and attach it to this body. Use this function if you need to set some fixture parameters, like friction. Otherwise you can create the fixture directly from a shape. If the density is non-zero, this function automatically updates the mass of the body. Contacts are not created until the next time step.

Parameters
def:FixtureDef

the fixture definition.

createFixtureback to summary
public Fixture createFixture(Shape shape, float density)

Creates a fixture from a shape and attach it to this body. This is a convenience function. Use b2FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. If the density is non-zero, this function automatically updates the mass of the body.

Parameters
shape:Shape

the shape to be cloned.

density:float

the shape density (set to zero for static bodies).

destroyFixtureback to summary
public void destroyFixture(Fixture fixture)

Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All fixtures attached to a body are implicitly destroyed when the body is destroyed.

Parameters
fixture:Fixture

the fixture to be removed.

getAngleback to summary
public float getAngle()

Get the angle in radians.

Returns:float

the current world rotation angle in radians.

getAngularDampingback to summary
public float getAngularDamping()

Get the angular damping of the body.

getAngularVelocityback to summary
public float getAngularVelocity()

Get the angular velocity.

getFixtureListback to summary
public Array<Fixture> getFixtureList()

Get the list of all fixtures attached to this body. Do not modify the list!

getGravityScaleback to summary
public float getGravityScale()
Returns:float

Get the gravity scale of the body.

getInertiaback to summary
public float getInertia()

Get the rotational inertia of the body about the local origin.

Returns:float

the rotational inertia, usually in kg-m^2.

getJointListback to summary
public Array<JointEdge> getJointList()

Get the list of all joints attached to this body. Do not modify the list!

getLinearDampingback to summary
public float getLinearDamping()

Get the linear damping of the body.

getLinearVelocityback to summary
public Vector2 getLinearVelocity()

Get the linear velocity of the center of mass. Note that the same Vector2 instance is returned each time this method is called.

getLinearVelocityFromLocalPointback to summary
public Vector2 getLinearVelocityFromLocalPoint(Vector2 localPoint)

Get the world velocity of a local point. Note that the same Vector2 instance is returned each time this method is called.

Parameters
localPoint:Vector2

a point in local coordinates.

Returns:Vector2

the world velocity of a point.

getLinearVelocityFromWorldPointback to summary
public Vector2 getLinearVelocityFromWorldPoint(Vector2 worldPoint)

Get the world linear velocity of a world point attached to this body. Note that the same Vector2 instance is returned each time this method is called.

Parameters
worldPoint:Vector2

a point in world coordinates.

Returns:Vector2

the world velocity of a point.

getLocalCenterback to summary
public Vector2 getLocalCenter()

Get the local position of the center of mass. Note that the same Vector2 instance is returned each time this method is called.

getLocalPointback to summary
public Vector2 getLocalPoint(Vector2 worldPoint)

Gets a local point relative to the body's origin given a world point. Note that the same Vector2 instance is returned each time this method is called.

Parameters
worldPoint:Vector2

a point in world coordinates.

Returns:Vector2

the corresponding local point relative to the body's origin.

getLocalVectorback to summary
public Vector2 getLocalVector(Vector2 worldVector)

Gets a local vector given a world vector. Note that the same Vector2 instance is returned each time this method is called.

Parameters
worldVector:Vector2

a vector in world coordinates.

Returns:Vector2

the corresponding local vector.

getMassback to summary
public float getMass()

Get the total mass of the body.

Returns:float

the mass, usually in kilograms (kg).

getMassDataback to summary
public MassData getMassData()

Get the mass data of the body.

Returns:MassData

a struct containing the mass, inertia and center of the body.

getPositionback to summary
public Vector2 getPosition()

Get the world body origin position. Note that the same Vector2 instance is returned each time this method is called.

Returns:Vector2

the world position of the body's origin.

getTransformback to summary
public Transform getTransform()

Get the body transform for the body's origin.

getTypeback to summary
public BodyDef.BodyType getType()

Get the type of this body.

getUserDataback to summary
public Object getUserData()

Get the user data

getWorldback to summary
public World getWorld()

Get the parent world of this body.

getWorldCenterback to summary
public Vector2 getWorldCenter()

Get the world position of the center of mass. Note that the same Vector2 instance is returned each time this method is called.

getWorldPointback to summary
public Vector2 getWorldPoint(Vector2 localPoint)

Get the world coordinates of a point given the local coordinates. Note that the same Vector2 instance is returned each time this method is called.

Parameters
localPoint:Vector2

a point on the body measured relative the the body's origin.

Returns:Vector2

the same point expressed in world coordinates.

getWorldVectorback to summary
public Vector2 getWorldVector(Vector2 localVector)

Get the world coordinates of a vector given the local coordinates. Note that the same Vector2 instance is returned each time this method is called.

Parameters
localVector:Vector2

a vector fixed in the body.

Returns:Vector2

the same vector expressed in world coordinates.

isActiveback to summary
public boolean isActive()

Get the active state of the body.

isAwakeback to summary
public boolean isAwake()

Get the sleeping state of this body.

Returns:boolean

true if the body is not sleeping.

isBulletback to summary
public boolean isBullet()

Is this body treated like a bullet for continuous collision detection?

isFixedRotationback to summary
public boolean isFixedRotation()

Does this body have fixed rotation?

isSleepingAllowedback to summary
public boolean isSleepingAllowed()

Is this body allowed to sleep

jniApplyAngularImpulseback to summary
private native void jniApplyAngularImpulse(long addr, float impulse, boolean wake)
jniApplyForceback to summary
private native void jniApplyForce(long addr, float forceX, float forceY, float pointX, float pointY, boolean wake)
jniApplyForceToCenterback to summary
private native void jniApplyForceToCenter(long addr, float forceX, float forceY, boolean wake)
jniApplyLinearImpulseback to summary
private native void jniApplyLinearImpulse(long addr, float impulseX, float impulseY, float pointX, float pointY, boolean wake)
jniApplyTorqueback to summary
private native void jniApplyTorque(long addr, float torque, boolean wake)
jniCreateFixtureback to summary
private native long jniCreateFixture(long addr, long shapeAddr, float friction, float restitution, float density, boolean isSensor, short filterCategoryBits, short filterMaskBits, short filterGroupIndex)
jniCreateFixtureback to summary
private native long jniCreateFixture(long addr, long shapeAddr, float density)
jniGetAngleback to summary
private native float jniGetAngle(long addr)
jniGetAngularDampingback to summary
private native float jniGetAngularDamping(long addr)
jniGetAngularVelocityback to summary
private native float jniGetAngularVelocity(long addr)
jniGetGravityScaleback to summary
private native float jniGetGravityScale(long addr)
jniGetInertiaback to summary
private native float jniGetInertia(long addr)
jniGetLinearDampingback to summary
private native float jniGetLinearDamping(long addr)
jniGetLinearVelocityback to summary
private native void jniGetLinearVelocity(long addr, long linearVelocityAddr)
jniGetLinearVelocityFromLocalPointback to summary
private native void jniGetLinearVelocityFromLocalPoint(long addr, float localPointX, float localPointY, long linVelLocAddr)
jniGetLinearVelocityFromWorldPointback to summary
private native void jniGetLinearVelocityFromWorldPoint(long addr, float worldPointX, float worldPointY, long linVelWorldAddr)
jniGetLocalCenterback to summary
private native void jniGetLocalCenter(long addr, long localCenterAddr)
jniGetLocalPointback to summary
private native void jniGetLocalPoint(long addr, float worldPointX, float worldPointY, long localPointAddr)
jniGetLocalVectorback to summary
private native void jniGetLocalVector(long addr, float worldVectorX, float worldVectorY, long worldVectorAddr)
jniGetMassback to summary
private native float jniGetMass(long addr)
jniGetMassDataback to summary
private native void jniGetMassData(long addr, float[] massData)
jniGetPositionback to summary
private native void jniGetPosition(long addr, long positionAddr)
jniGetTransformback to summary
private native void jniGetTransform(long addr, float[] vals)
jniGetTypeback to summary
private native int jniGetType(long addr)
jniGetWorldCenterback to summary
private native void jniGetWorldCenter(long addr, long worldCenterAddr)
jniGetWorldPointback to summary
private native void jniGetWorldPoint(long addr, float localPointX, float localPointY, long worldPointAddr)
jniGetWorldVectorback to summary
private native void jniGetWorldVector(long addr, float localVectorX, float localVectorY, long worldVectorAddr)
jniIsActiveback to summary
private native boolean jniIsActive(long addr)
jniIsAwakeback to summary
private native boolean jniIsAwake(long addr)
jniIsBulletback to summary
private native boolean jniIsBullet(long addr)
jniIsFixedRotationback to summary
private native boolean jniIsFixedRotation(long addr)
jniIsSleepingAllowedback to summary
private native boolean jniIsSleepingAllowed(long addr)
jniResetMassDataback to summary
private native void jniResetMassData(long addr)
jniSetActiveback to summary
private native void jniSetActive(long addr, boolean flag)
jniSetAngularDampingback to summary
private native void jniSetAngularDamping(long addr, float angularDamping)
jniSetAngularVelocityback to summary
private native void jniSetAngularVelocity(long addr, float omega)
jniSetAwakeback to summary
private native void jniSetAwake(long addr, boolean flag)
jniSetBulletback to summary
private native void jniSetBullet(long addr, boolean flag)
jniSetFixedRotationback to summary
private native void jniSetFixedRotation(long addr, boolean flag)
jniSetGravityScaleback to summary
private native void jniSetGravityScale(long addr, float scale)
jniSetLinearDampingback to summary
private native void jniSetLinearDamping(long addr, float linearDamping)
jniSetLinearVelocityback to summary
private native void jniSetLinearVelocity(long addr, float x, float y)
jniSetMassDataback to summary
private native void jniSetMassData(long addr, float mass, float centerX, float centerY, float I)
jniSetSleepingAllowedback to summary
private native void jniSetSleepingAllowed(long addr, boolean flag)
jniSetTransformback to summary
private native void jniSetTransform(long addr, float positionX, float positionY, float angle)
jniSetTypeback to summary
private native void jniSetType(long addr, int type)
resetback to summary
protected void reset(long addr)

Resets this body after fetching it from the World#freeBodies Pool.

resetMassDataback to summary
public void resetMassData()

This resets the mass properties to the sum of the mass properties of the fixtures. This normally does not need to be called unless you called SetMassData to override the mass and you later want to reset the mass.

setActiveback to summary
public void setActive(boolean flag)

Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a b2World object and remains in the body list.

setAngularDampingback to summary
public void setAngularDamping(float angularDamping)

Set the angular damping of the body.

setAngularVelocityback to summary
public void setAngularVelocity(float omega)

Set the angular velocity.

setAwakeback to summary
public void setAwake(boolean flag)

Set the sleep state of the body. A sleeping body has very low CPU cost.

Parameters
flag:boolean

set to true to wake the body, false to put it to sleep.

setBulletback to summary
public void setBullet(boolean flag)

Should this body be treated like a bullet for continuous collision detection?

setFixedRotationback to summary
public void setFixedRotation(boolean flag)

Set this body to have fixed rotation. This causes the mass to be reset.

setGravityScaleback to summary
public void setGravityScale(float scale)

Sets the gravity scale of the body

setLinearDampingback to summary
public void setLinearDamping(float linearDamping)

Set the linear damping of the body.

setLinearVelocityback to summary
public void setLinearVelocity(Vector2 v)

Set the linear velocity of the center of mass.

setLinearVelocityback to summary
public void setLinearVelocity(float vX, float vY)

Set the linear velocity of the center of mass.

setMassDataback to summary
public void setMassData(MassData data)

Set the mass properties to override the mass properties of the fixtures. Note that this changes the center of mass position. Note that creating or destroying fixtures can also alter the mass. This function has no effect if the body isn't dynamic.

Parameters
data:MassData

the mass properties.

setSleepingAllowedback to summary
public void setSleepingAllowed(boolean flag)

You can disable sleeping on this body. If you disable sleeping, the

setTransformback to summary
public void setTransform(Vector2 position, float angle)

Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior.

Parameters
position:Vector2

the world position of the body's local origin.

angle:float

the world rotation in radians.

setTransformback to summary
public void setTransform(float x, float y, float angle)

Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior.

Parameters
x:float

the world position on the x-axis

y:float

the world position on the y-axis

angle:float

the world rotation in radians.

setTypeback to summary
public void setType(BodyDef.BodyType type)

Set the type of this body. This may alter the mass and velocity.

setUserDataback to summary
public void setUserData(Object userData)

Set the user data