Body class

A rigid body. These are created via World.createBody.


Body(BodyDef bd, World world)


angularDamping double
read / write
angularVelocity double
Get the angular velocity. [...]
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
linearVelocity Vector2
Get the linear velocity of the center of mass. Do not modify, instead use {@link #setLinearVelocity(Vec2)}. [...]
read / write
mass double
Get the total mass of the body. [...]
position Vector2
Get the world body origin position. Do not modify. [...]
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
userData Object
Use this to store your application specific data.
read / write
world World
worldCenter Vector2
Get the world position of the center of mass. Do not modify.


advance(double t) → void
applyAngularImpulse(double impulse) → void
Apply an angular impulse. [...]
applyForce(Vector2 force, Vector2 point) → void
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. [...]
applyForceToCenter(Vector2 force) → void
Apply a force to the center of mass. This wakes up the body. [...]
applyLinearImpulse(Vector2 impulse, Vector2 point, bool wake) → void
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 if 'wake' is set to true. If the body is sleeping and 'wake' is false, then there is no effect. [...]
applyTorque(double torque) → void
Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body. [...]
createFixtureFromFixtureDef(FixtureDef def) Fixture
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. [...]
createFixtureFromShape(Shape shape, [double density = 0.0]) Fixture
Creates a fixture from a shape and attach it to this body. This is a convenience function. Use FixtureDef 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. [...]
destroyFixture(Fixture fixture) → void
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. [...]
getAngle() double
Get the angle in radians. [...]
getContactList() ContactEdge
Get the list of all contacts attached to this body. [...]
getFixtureList() Fixture
Get the list of all fixtures attached to this body.
getInertia() double
Get the central rotational inertia of the body. [...]
getJointList() JointEdge
Get the list of all joints attached to this body.
getLinearVelocityFromLocalPoint(Vector2 localPoint) Vector2
Get the world velocity of a local point. [...]
getLinearVelocityFromLocalPointToOut(Vector2 localPoint, Vector2 out) → void
getLinearVelocityFromWorldPoint(Vector2 worldPoint) Vector2
Get the world linear velocity of a world point attached to this body. [...]
getLinearVelocityFromWorldPointToOut(Vector2 worldPoint, Vector2 out) → void
getLocalCenter() Vector2
Get the local position of the center of mass. Do not modify.
getLocalPoint(Vector2 worldPoint) Vector2
Gets a local point relative to the body's origin given a world point. [...]
getLocalPointToOut(Vector2 worldPoint, Vector2 out) → void
getLocalVector(Vector2 worldVector) Vector2
Gets a local vector given a world vector. [...]
getLocalVectorToOut(Vector2 worldVector, Vector2 out) → void
getLocalVectorToOutUnsafe(Vector2 worldVector, Vector2 out) → void
getMassData(MassData data) → void
Get the mass data of the body. The rotational inertia is relative to the center of mass. [...]
getNext() Body
Get the next body in the world's body list.
getType() BodyType
getWorldPoint(Vector2 localPoint) Vector2
Get the world coordinates of a point given the local coordinates. [...]
getWorldPointToOut(Vector2 localPoint, Vector2 out) → void
getWorldVector(Vector2 localVector) Vector2
Get the world coordinates of a vector given the local coordinates. [...]
getWorldVectorToOut(Vector2 localVector, Vector2 out) → void
getWorldVectorToOutUnsafe(Vector2 localVector, Vector2 out) → void
isActive() bool
Get the active state of the body. [...]
isAwake() bool
Get the sleeping state of this body. [...]
isBullet() bool
Is this body treated like a bullet for continuous collision detection?
isFixedRotation() bool
Does this body have fixed rotation? [...]
isSleepingAllowed() bool
Is this body allowed to sleep [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
resetMassData() → void
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.
setActive(bool flag) → void
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 World object and remains in the body list.
setAwake(bool flag) → void
Set the sleep state of the body. A sleeping body has very low CPU cost. [...]
setBullet(bool flag) → void
Should this body be treated like a bullet for continuous collision detection?
setFixedRotation(bool flag) → void
Set this body to have fixed rotation. This causes the mass to be reset. [...]
setMassData(MassData massData) → void
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. [...]
setSleepingAllowed(bool flag) → void
You can disable sleeping on this body. If you disable sleeping, the body will be woken. [...]
setTransform(Vector2 position, double angle) → void
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. Note: contacts are updated on the next call to World.step(). [...]
setType(BodyType type) → void
Set the type of this body. This may alter the mass and velocity. [...]
shouldCollide(Body other) bool
This is used to prevent connected bodies from colliding. It may lie, depending on the collideConnected flag. [...]
synchronizeFixtures() → void
synchronizeTransform() → void
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]


ACTIVE_FLAG → const int
AUTO_SLEEP_FLAG → const int
AWAKE_FLAG → const int
BULLET_FLAG → const int
ISLAND_FLAG → const int
TOI_FLAG → const int