public class Body extends Object
Modifier and Type | Field and Description |
---|---|
Vector2 |
linVelLoc |
Vector2 |
linVelWorld |
Vector2 |
localPoint2 |
Vector2 |
localVector |
Modifier and Type | Method and Description |
---|---|
void |
applyAngularImpulse(float impulse,
boolean wake)
Apply an angular impulse.
|
void |
applyForce(float forceX,
float forceY,
float pointX,
float pointY,
boolean wake)
Apply a force at a world point.
|
void |
applyForce(Vector2 force,
Vector2 point,
boolean wake)
Apply a force at a world point.
|
void |
applyForceToCenter(float forceX,
float forceY,
boolean wake)
Apply a force to the center of mass.
|
void |
applyForceToCenter(Vector2 force,
boolean wake)
Apply a force to the center of mass.
|
void |
applyLinearImpulse(float impulseX,
float impulseY,
float pointX,
float pointY,
boolean wake)
Apply an impulse at a point.
|
void |
applyLinearImpulse(Vector2 impulse,
Vector2 point,
boolean wake)
Apply an impulse at a point.
|
void |
applyTorque(float torque,
boolean wake)
Apply a torque.
|
Fixture |
createFixture(FixtureDef def)
Creates a fixture and attach it to this body.
|
Fixture |
createFixture(Shape shape,
float density)
Creates a fixture from a shape and attach it to this body.
|
void |
destroyFixture(Fixture fixture)
Destroy a fixture.
|
float |
getAngle()
Get the angle in radians.
|
float |
getAngularDamping()
Get the angular damping of the body.
|
float |
getAngularVelocity()
Get the angular velocity.
|
Array<Fixture> |
getFixtureList()
Get the list of all fixtures attached to this body.
|
float |
getGravityScale() |
float |
getInertia()
Get the rotational inertia of the body about the local origin.
|
Array<JointEdge> |
getJointList()
Get the list of all joints attached to this body.
|
float |
getLinearDamping()
Get the linear damping of the body.
|
Vector2 |
getLinearVelocity()
Get the linear velocity of the center of mass.
|
Vector2 |
getLinearVelocityFromLocalPoint(Vector2 localPoint)
Get the world velocity of a local point.
|
Vector2 |
getLinearVelocityFromWorldPoint(Vector2 worldPoint)
Get the world linear velocity of a world point attached to this body.
|
Vector2 |
getLocalCenter()
Get the local position of the center of mass.
|
Vector2 |
getLocalPoint(Vector2 worldPoint)
Gets a local point relative to the body's origin given a world point.
|
Vector2 |
getLocalVector(Vector2 worldVector)
Gets a local vector given a world vector.
|
float |
getMass()
Get the total mass of the body.
|
MassData |
getMassData()
Get the mass data of the body.
|
Vector2 |
getPosition()
Get the world body origin position.
|
Transform |
getTransform()
Get the body transform for the body's origin.
|
BodyDef.BodyType |
getType()
Get the type of this body.
|
Object |
getUserData()
Get the user data
|
World |
getWorld()
Get the parent world of this body.
|
Vector2 |
getWorldCenter()
Get the world position of the center of mass.
|
Vector2 |
getWorldPoint(Vector2 localPoint)
Get the world coordinates of a point given the local coordinates.
|
Vector2 |
getWorldVector(Vector2 localVector)
Get the world coordinates of a vector given the local coordinates.
|
boolean |
isActive()
Get the active state of the body.
|
boolean |
isAwake()
Get the sleeping state of this body.
|
boolean |
isBullet()
Is this body treated like a bullet for continuous collision detection?
|
boolean |
isFixedRotation()
Does this body have fixed rotation?
|
boolean |
isSleepingAllowed()
Is this body allowed to sleep
|
void |
resetMassData()
This resets the mass properties to the sum of the mass properties of the fixtures.
|
void |
setActive(boolean flag)
Set the active state of the body.
|
void |
setAngularDamping(float angularDamping)
Set the angular damping of the body.
|
void |
setAngularVelocity(float omega)
Set the angular velocity.
|
void |
setAwake(boolean flag)
Set the sleep state of the body.
|
void |
setBullet(boolean flag)
Should this body be treated like a bullet for continuous collision detection?
|
void |
setFixedRotation(boolean flag)
Set this body to have fixed rotation.
|
void |
setGravityScale(float scale)
Sets the gravity scale of the body
|
void |
setLinearDamping(float linearDamping)
Set the linear damping of the body.
|
void |
setLinearVelocity(float vX,
float vY)
Set the linear velocity of the center of mass.
|
void |
setLinearVelocity(Vector2 v)
Set the linear velocity of the center of mass.
|
void |
setMassData(MassData data)
Set the mass properties to override the mass properties of the fixtures.
|
void |
setSleepingAllowed(boolean flag)
You can disable sleeping on this body.
|
void |
setTransform(float x,
float y,
float angle)
Set the position of the body's origin and rotation.
|
void |
setTransform(Vector2 position,
float angle)
Set the position of the body's origin and rotation.
|
void |
setType(BodyDef.BodyType type)
Set the type of this body.
|
void |
setUserData(Object userData)
Set the user data
|
public final Vector2 localPoint2
public final Vector2 localVector
public final Vector2 linVelWorld
public final Vector2 linVelLoc
public Fixture createFixture(FixtureDef def)
def
- the fixture definition.public Fixture createFixture(Shape shape, float density)
shape
- the shape to be cloned.density
- the shape density (set to zero for static bodies).public void destroyFixture(Fixture fixture)
fixture
- the fixture to be removed.public void setTransform(Vector2 position, float angle)
position
- the world position of the body's local origin.angle
- the world rotation in radians.public void setTransform(float x, float y, float angle)
x
- the world position on the x-axisy
- the world position on the y-axisangle
- the world rotation in radians.public Transform getTransform()
public Vector2 getPosition()
public float getAngle()
public Vector2 getWorldCenter()
public Vector2 getLocalCenter()
public void setLinearVelocity(Vector2 v)
public void setLinearVelocity(float vX, float vY)
public Vector2 getLinearVelocity()
public void setAngularVelocity(float omega)
public float getAngularVelocity()
public void applyForce(Vector2 force, Vector2 point, boolean wake)
force
- the world force vector, usually in Newtons (N).point
- the world position of the point of application.wake
- up the bodypublic void applyForce(float forceX, float forceY, float pointX, float pointY, boolean wake)
forceX
- the world force vector on x, usually in Newtons (N).forceY
- the world force vector on y, usually in Newtons (N).pointX
- the world position of the point of application on x.pointY
- the world position of the point of application on y.wake
- up the bodypublic void applyForceToCenter(Vector2 force, boolean wake)
force
- the world force vector, usually in Newtons (N).public void applyForceToCenter(float forceX, float forceY, boolean wake)
forceX
- the world force vector, usually in Newtons (N).forceY
- the world force vector, usually in Newtons (N).public void applyTorque(float torque, boolean wake)
torque
- about the z-axis (out of the screen), usually in N-m.wake
- up the bodypublic void applyLinearImpulse(Vector2 impulse, Vector2 point, boolean wake)
impulse
- the world impulse vector, usually in N-seconds or kg-m/s.point
- the world position of the point of application.wake
- up the bodypublic void applyLinearImpulse(float impulseX, float impulseY, float pointX, float pointY, boolean wake)
impulseX
- the world impulse vector on the x-axis, usually in N-seconds or kg-m/s.impulseY
- the world impulse vector on the y-axis, usually in N-seconds or kg-m/s.pointX
- the world position of the point of application on the x-axis.pointY
- the world position of the point of application on the y-axis.wake
- up the bodypublic void applyAngularImpulse(float impulse, boolean wake)
impulse
- the angular impulse in units of kg*m*m/spublic float getMass()
public float getInertia()
public MassData getMassData()
public void setMassData(MassData data)
data
- the mass properties.public void resetMassData()
public Vector2 getWorldPoint(Vector2 localPoint)
localPoint
- a point on the body measured relative the the body's origin.public Vector2 getWorldVector(Vector2 localVector)
localVector
- a vector fixed in the body.public Vector2 getLocalPoint(Vector2 worldPoint)
worldPoint
- a point in world coordinates.public Vector2 getLocalVector(Vector2 worldVector)
worldVector
- a vector in world coordinates.public Vector2 getLinearVelocityFromWorldPoint(Vector2 worldPoint)
worldPoint
- a point in world coordinates.public Vector2 getLinearVelocityFromLocalPoint(Vector2 localPoint)
localPoint
- a point in local coordinates.public float getLinearDamping()
public void setLinearDamping(float linearDamping)
public float getAngularDamping()
public void setAngularDamping(float angularDamping)
public void setType(BodyDef.BodyType type)
public BodyDef.BodyType getType()
public void setBullet(boolean flag)
public boolean isBullet()
public void setSleepingAllowed(boolean flag)
public boolean isSleepingAllowed()
public void setAwake(boolean flag)
flag
- set to true to wake the body, false to put it to sleep.public boolean isAwake()
public void setActive(boolean flag)
public boolean isActive()
public void setFixedRotation(boolean flag)
public boolean isFixedRotation()
public Array<Fixture> getFixtureList()
public Array<JointEdge> getJointList()
public float getGravityScale()
public void setGravityScale(float scale)
public World getWorld()
public Object getUserData()
public void setUserData(Object userData)
Copyright © 2020. All rights reserved.