|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.physics.box2d.Body
public class Body
A rigid body. These are created via World.CreateBody.
Field Summary | |
---|---|
protected long |
addr
the address of the body |
protected java.util.ArrayList<JointEdge> |
joints
Joints of this body |
Vector2 |
linVelLoc
|
Vector2 |
linVelWorld
|
Vector2 |
localPoint2
|
Vector2 |
localVector
|
Constructor Summary | |
---|---|
protected |
Body(World world,
long addr)
Constructs a new body with the given address |
Method Summary | |
---|---|
void |
applyAngularImpulse(float impulse)
Apply an angular impulse. |
void |
applyForce(float forceX,
float forceY,
float pointX,
float pointY)
Apply a force at a world point. |
void |
applyForce(Vector2 force,
Vector2 point)
Apply a force at a world point. |
void |
applyForceToCenter(float forceX,
float forceY)
Apply a force to the center of mass. |
void |
applyForceToCenter(Vector2 force)
Apply a force to the center of mass. |
void |
applyLinearImpulse(float impulseX,
float impulseY,
float pointX,
float pointY)
Apply an impulse at a point. |
void |
applyLinearImpulse(Vector2 impulse,
Vector2 point)
Apply an impulse at a point. |
void |
applyTorque(float torque)
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. |
java.util.ArrayList<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. |
java.util.ArrayList<JointEdge> |
getJointList()
Get the list of all joints attached to this body. |
float |
getLinearDamping()
Get the linear damping of the body. |
Vector2 |
getLinearVelocity()
|
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()
|
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()
|
BodyDef.BodyType |
getType()
Get the type of this body. |
java.lang.Object |
getUserData()
Get the user data |
World |
getWorld()
Get the parent world of this body. |
Vector2 |
getWorldCenter()
|
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 |
protected void |
reset(long addr)
Resets this body after fetching it from the World.freeBodies Pool. |
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(java.lang.Object userData)
Set the user data |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected long addr
protected java.util.ArrayList<JointEdge> joints
public final Vector2 localPoint2
public final Vector2 localVector
public final Vector2 linVelWorld
public final Vector2 linVelLoc
Constructor Detail |
---|
protected Body(World world, long addr)
world
- the worldaddr
- the addressMethod Detail |
---|
protected void reset(long addr)
World.freeBodies
Pool.
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)
force
- the world force vector, usually in Newtons (N).point
- the world position of the point of application.public void applyForce(float forceX, float forceY, float pointX, float pointY)
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.public void applyForceToCenter(Vector2 force)
force
- the world force vector, usually in Newtons (N).forceX
- forceY
- public void applyForceToCenter(float forceX, float forceY)
force
- the world force vector, usually in Newtons (N).forceX
- forceY
- public void applyTorque(float torque)
torque
- about the z-axis (out of the screen), usually in N-m.public void applyLinearImpulse(Vector2 impulse, Vector2 point)
impulse
- the world impulse vector, usually in N-seconds or kg-m/s.point
- the world position of the point of application.public void applyLinearImpulse(float impulseX, float impulseY, float pointX, float pointY)
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.public void applyAngularImpulse(float impulse)
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 put body to sleep, false to wake it.public boolean isAwake()
public void setActive(boolean flag)
public boolean isActive()
public void setFixedRotation(boolean flag)
public boolean isFixedRotation()
public java.util.ArrayList<Fixture> getFixtureList()
public java.util.ArrayList<JointEdge> getJointList()
public float getGravityScale()
public void setGravityScale(float scale)
public World getWorld()
public java.lang.Object getUserData()
public void setUserData(java.lang.Object userData)
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |