PackageBox2D.Dynamics
Classpublic class b2Body
Sourceb2Body.as

A rigid body.



Public Methods
 MethodDefined by
  
AllowSleeping(flag:Boolean):void
You can disable sleeping on this body.
b2Body
  
ApplyForce(force:b2Vec2, point:b2Vec2):void
Apply a force at a world point.
b2Body
  
ApplyImpulse(impulse:b2Vec2, point:b2Vec2):void
Apply an impulse at a point.
b2Body
  
ApplyTorque(torque:Number):void
Apply a torque.
b2Body
  
Creates a shape and attach it to this body.
b2Body
  
Destroy a shape.
b2Body
  
GetAngle():Number
Get the angle in radians.
b2Body
  
Get the angular velocity.
b2Body
  
GetInertia():Number
Get the central rotational inertia of the body.
b2Body
  
Get the list of all joints attached to this body.
b2Body
  
Get the linear velocity of the center of mass.
b2Body
  
Get the world velocity of a local point.
b2Body
  
Get the world linear velocity of a world point attached to this body.
b2Body
  
Get the local position of the center of mass.
b2Body
  
Gets a local point relative to the body's origin given a world point.
b2Body
  
Gets a local vector given a world vector.
b2Body
  
GetMass():Number
Get the total mass of the body.
b2Body
  
Get the next body in the world's body list.
b2Body
  
Get the world body origin position.
b2Body
  
Get the list of all shapes attached to this body.
b2Body
  
Get the user data pointer that was provided in the body definition.
b2Body
  
Get the parent world of this body.
b2Body
  
Get the world position of the center of mass.
b2Body
  
Get the world coordinates of a point given the local coordinates.
b2Body
  
Get the world coordinates of a vector given the local coordinates.
b2Body
  
Get the body transform for the body's origin.
b2Body
  
IsBullet():Boolean
Is this body treated like a bullet for continuous collision detection?
b2Body
  
IsDynamic():Boolean
Is this body dynamic (movable)?
b2Body
  
IsFrozen():Boolean
Is this body frozen?
b2Body
  
IsSleeping():Boolean
Is this body sleeping (not simulating).
b2Body
  
IsStatic():Boolean
Is this body static (immovable)?
b2Body
  
PutToSleep():void
Put this body to sleep so it will stop simulating.
b2Body
  
SetAngularVelocity(omega:Number):void
Set the angular velocity.
b2Body
  
SetBullet(flag:Boolean):void
Should this body be treated like a bullet for continuous collision detection?
b2Body
  
Set the linear velocity of the center of mass.
b2Body
  
SetMass(massData:b2MassData):void
Set the mass properties.
b2Body
  
Compute the mass properties from the attached shapes.
b2Body
  
SetUserData(data:*):void
Set the user data.
b2Body
  
SetXForm(position:b2Vec2, angle:Number):Boolean
Set the position of the body's origin and rotation (radians).
b2Body
  
WakeUp():void
Wake up this body so it will begin simulating.
b2Body
Method detail
AllowSleeping()method
public function AllowSleeping(flag:Boolean):void

You can disable sleeping on this body.

Parameters
flag:Boolean
ApplyForce()method 
public function ApplyForce(force:b2Vec2, point:b2Vec2):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.

Parameters
force:b2Vec2 — the world force vector, usually in Newtons (N).
 
point:b2Vec2 — the world position of the point of application.
ApplyImpulse()method 
public function ApplyImpulse(impulse:b2Vec2, point:b2Vec2):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.

Parameters
impulse:b2Vec2 — the world impulse vector, usually in N-seconds or kg-m/s.
 
point:b2Vec2 — the world position of the point of application.
ApplyTorque()method 
public function ApplyTorque(torque:Number):void

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:Number — about the z-axis (out of the screen), usually in N-m.
CreateShape()method 
public function CreateShape(def:b2ShapeDef):b2Shape

Creates a shape and attach it to this body.

Warning: This function is locked during callbacks.

Parameters
def:b2ShapeDef — the shape definition.

Returns
b2Shape
DestroyShape()method 
public function DestroyShape(s:b2Shape):void

Destroy a shape. This removes the shape from the broad-phase and therefore destroys any contacts associated with this shape. All shapes attached to a body are implicitly destroyed when the body is destroyed.

Warning: This function is locked during callbacks.

Parameters
s:b2Shape — the shape to be removed.
GetAngle()method 
public function GetAngle():Number

Get the angle in radians.

Returns
Number — the current world rotation angle in radians.
GetAngularVelocity()method 
public function GetAngularVelocity():Number

Get the angular velocity.

Returns
Number — the angular velocity in radians/second.
GetInertia()method 
public function GetInertia():Number

Get the central rotational inertia of the body.

Returns
Number — the rotational inertia, usually in kg-m^2.
GetJointList()method 
public function GetJointList():b2JointEdge

Get the list of all joints attached to this body.

Returns
b2JointEdge
GetLinearVelocity()method 
public function GetLinearVelocity():b2Vec2

Get the linear velocity of the center of mass.

Returns
b2Vec2 — the linear velocity of the center of mass.
GetLinearVelocityFromLocalPoint()method 
public function GetLinearVelocityFromLocalPoint(localPoint:b2Vec2):b2Vec2

Get the world velocity of a local point.

Parameters
localPoint:b2Vec2 — point in local coordinates.

Returns
b2Vec2 — the world velocity of a point.
GetLinearVelocityFromWorldPoint()method 
public function GetLinearVelocityFromWorldPoint(worldPoint:b2Vec2):b2Vec2

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

Parameters
worldPoint:b2Vec2 — point in world coordinates.

Returns
b2Vec2 — the world velocity of a point.
GetLocalCenter()method 
public function GetLocalCenter():b2Vec2

Get the local position of the center of mass.

Returns
b2Vec2
GetLocalPoint()method 
public function GetLocalPoint(worldPoint:b2Vec2):b2Vec2

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

Parameters
worldPoint:b2Vec2 — point in world coordinates.

Returns
b2Vec2 — the corresponding local point relative to the body's origin.
GetLocalVector()method 
public function GetLocalVector(worldVector:b2Vec2):b2Vec2

Gets a local vector given a world vector.

Parameters
worldVector:b2Vec2 — vector in world coordinates.

Returns
b2Vec2 — the corresponding local vector.
GetMass()method 
public function GetMass():Number

Get the total mass of the body.

Returns
Number — the mass, usually in kilograms (kg).
GetNext()method 
public function GetNext():b2Body

Get the next body in the world's body list.

Returns
b2Body
GetPosition()method 
public function GetPosition():b2Vec2

Get the world body origin position.

Returns
b2Vec2 — the world position of the body's origin.
GetShapeList()method 
public function GetShapeList():b2Shape

Get the list of all shapes attached to this body.

Returns
b2Shape
GetUserData()method 
public function GetUserData():*

Get the user data pointer that was provided in the body definition.

Returns
*
GetWorld()method 
public function GetWorld():b2World

Get the parent world of this body.

Returns
b2World
GetWorldCenter()method 
public function GetWorldCenter():b2Vec2

Get the world position of the center of mass.

Returns
b2Vec2
GetWorldPoint()method 
public function GetWorldPoint(localPoint:b2Vec2):b2Vec2

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

Parameters
localPoint:b2Vec2 — a point on the body measured relative the the body's origin.

Returns
b2Vec2 — the same point expressed in world coordinates.
GetWorldVector()method 
public function GetWorldVector(localVector:b2Vec2):b2Vec2

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

Parameters
localVector:b2Vec2 — a vector fixed in the body.

Returns
b2Vec2 — the same vector expressed in world coordinates.
GetXForm()method 
public function GetXForm():b2XForm

Get the body transform for the body's origin.

Returns
b2XForm — the world transform of the body's origin.
IsBullet()method 
public function IsBullet():Boolean

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

Returns
Boolean
IsDynamic()method 
public function IsDynamic():Boolean

Is this body dynamic (movable)?

Returns
Boolean
IsFrozen()method 
public function IsFrozen():Boolean

Is this body frozen?

Returns
Boolean
IsSleeping()method 
public function IsSleeping():Boolean

Is this body sleeping (not simulating).

Returns
Boolean
IsStatic()method 
public function IsStatic():Boolean

Is this body static (immovable)?

Returns
Boolean
PutToSleep()method 
public function PutToSleep():void

Put this body to sleep so it will stop simulating. This also sets the velocity to zero.

SetAngularVelocity()method 
public function SetAngularVelocity(omega:Number):void

Set the angular velocity.

Parameters
omega:Number — the new angular velocity in radians/second.
SetBullet()method 
public function SetBullet(flag:Boolean):void

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

Parameters
flag:Boolean
SetLinearVelocity()method 
public function SetLinearVelocity(v:b2Vec2):void

Set the linear velocity of the center of mass.

Parameters
v:b2Vec2 — the new linear velocity of the center of mass.
SetMass()method 
public function SetMass(massData:b2MassData):void

Set the mass properties. Note that this changes the center of mass position. If you are not sure how to compute mass properties, use SetMassFromShapes. The inertia tensor is assumed to be relative to the center of mass.

Parameters
massData:b2MassData — the mass properties.
SetMassFromShapes()method 
public function SetMassFromShapes():void

Compute the mass properties from the attached shapes. You typically call this after adding all the shapes. If you add or remove shapes later, you may want to call this again. Note that this changes the center of mass position.

SetUserData()method 
public function SetUserData(data:*):void

Set the user data. Use this to store your application specific data.

Parameters
data:*
SetXForm()method 
public function SetXForm(position:b2Vec2, angle:Number):Boolean

Set the position of the body's origin and rotation (radians). This breaks any contacts and wakes the other bodies.

Parameters
position:b2Vec2 — the new world position of the body's origin (not necessarily the center of mass).
 
angle:Number — the new world rotation angle of the body in radians.

Returns
Boolean — false if the movement put a shape outside the world. In this case the body is automatically frozen.
WakeUp()method 
public function WakeUp():void

Wake up this body so it will begin simulating.