B2Body
From Box2D Wiki
| b2Body | |
|---|---|
| Box2D/Dynamics | |
| Visibility | Public |
| Definition Object | b2BodyDef |
| Manual reference | [1] |
| API reference | [2] |
| Source reference |
|
b2Body is the object used to represent one rigid body. The entire world is built out of bodies.
b2Body stores all the dynamic properties; its position, rotation, and motion. It also has a number of flags that determine its current behaviour in the world, see sensors, bullets, sleeping and frozen.
However the material properties and the description of the shape or form of the body is specified by the list of shapes it contains. This can be manipulated by GetShapeList, CreateShape and DestroyShape.
Properties
| Type | Definition | Getter | Setter |
|---|---|---|---|
| Dynamic | |||
| b2MassData | massData
fixedRotation | GetMass
GetInertia GetWorldCenter | SetMass |
| b2Vec2
float32 | position
angle | GetPosition
GetAngle GetXForm | SetXForm |
| b2Vec2 | GetLinearVelocity | SetLinearVelocity | |
| b2Vec2 | GetAngularVelocity | SetAngularVelocity | |
| float32 | linearDamping | ||
| float32 | angularDamping | ||
| Lists | |||
| b2Shape* | GetShapeList | CreateShape
DestroyShape | |
| b2JointEdge* | GetJointList | ||
| b2ContactEdge* | GetContactList | ||
| b2Body* | GetNext | ||
| Flags | |||
| bool | allowSleep | AllowSleeping | |
| bool | isSleeping | IsSleeping | WakeUp |
| bool | isBullet | IsBullet | SetBullet |
| bool | See here | IsStatic
IsDynamic | |
| bool | IsFrozen | ||
| Misc | |||
| void* | userData | GetUserData | |
Methods
SetMassFromShapes
The b2Body.SetMassFromShapes method calculates the mass and center of mass of a body by using the size and density of each of the shapes attached to the body. This is the default and recommended way of creating a dynamic body; if you want more precise control over a body's mass, you will have to create a MassData object.
- GetWorldCenter/GetLocalCenter
- ApplyForce
- ApplyTorque
- ApplyImpulse
- GetWorldPoint/GetLocalPoint
- GetWorldVector/GetLocalVector


