PackageBox2D.Dynamics
Classpublic class b2Body
Sourceb2Body.as

A rigid body.



Public Properties
 PropertyDefined by
  e_allowSleepFlag : uint = 0x0010
[static]
b2Body
  e_bulletFlag : uint = 0x0020
[static]
b2Body
  e_dynamicType : uint = 2
[static]
b2Body
  e_fixedRotationFlag : uint = 0x0040
[static]
b2Body
  e_frozenFlag : uint = 0x0002
[static]
b2Body
  e_islandFlag : uint = 0x0004
[static]
b2Body
  e_maxTypes : uint = 3
[static]
b2Body
  e_sleepFlag : uint = 0x0008
[static]
b2Body
  e_staticType : uint = 1
[static]
b2Body
  m_angularDamping : Number
b2Body
  m_angularVelocity : Number
b2Body
  m_contactList : b2ContactEdge
b2Body
  m_flags : uint
b2Body
  m_force : b2Vec2
b2Body
  m_I : Number
b2Body
  m_jointList : b2JointEdge
b2Body
  m_linearDamping : Number
b2Body
  m_linearVelocity : b2Vec2
b2Body
  m_mass : Number
b2Body
  m_next : b2Body
b2Body
  m_prev : b2Body
b2Body
  m_shapeCount : int
b2Body
  m_shapeList : b2Shape
b2Body
  m_sleepTime : Number
b2Body
  m_sweep : b2Sweep
b2Body
  m_torque : Number
b2Body
  m_type : int
b2Body
  m_userData : *
b2Body
  m_world : b2World
b2Body
  m_xf : b2XForm
b2Body
Public Methods
 MethodDefined by
  
b2Body
  
Advance(t:Number):void
b2Body
  
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
  
IsConnected(other:b2Body):Boolean
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
  
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
  
b2Body
  
b2Body
  
WakeUp():void
Wake up this body so it will begin simulating.
b2Body
Property detail
e_allowSleepFlagproperty
public static var e_allowSleepFlag:uint = 0x0010
e_bulletFlagproperty 
public static var e_bulletFlag:uint = 0x0020
e_dynamicTypeproperty 
public static var e_dynamicType:uint = 2
e_fixedRotationFlagproperty 
public static var e_fixedRotationFlag:uint = 0x0040
e_frozenFlagproperty 
public static var e_frozenFlag:uint = 0x0002
e_islandFlagproperty 
public static var e_islandFlag:uint = 0x0004
e_maxTypesproperty 
public static var e_maxTypes:uint = 3
e_sleepFlagproperty 
public static var e_sleepFlag:uint = 0x0008
e_staticTypeproperty 
public static var e_staticType:uint = 1
m_angularDampingproperty 
public var m_angularDamping:Number
m_angularVelocityproperty 
public var m_angularVelocity:Number
m_contactListproperty 
public var m_contactList:b2ContactEdge
m_flagsproperty 
public var m_flags:uint
m_forceproperty 
public var m_force:b2Vec2
m_Iproperty 
public var m_I:Number
m_jointListproperty 
public var m_jointList:b2JointEdge
m_linearDampingproperty 
public var m_linearDamping:Number
m_linearVelocityproperty 
public var m_linearVelocity:b2Vec2
m_massproperty 
public var m_mass:Number
m_nextproperty 
public var m_next:b2Body
m_prevproperty 
public var m_prev:b2Body
m_shapeCountproperty 
public var m_shapeCount:int
m_shapeListproperty 
public var m_shapeList:b2Shape
m_sleepTimeproperty 
public var m_sleepTime:Number
m_sweepproperty 
public var m_sweep:b2Sweep
m_torqueproperty 
public var m_torque:Number
m_typeproperty 
public var m_type:int
m_userDataproperty 
public var m_userData:*
m_worldproperty 
public var m_world:b2World
m_xfproperty 
public var m_xf:b2XForm
Constructor detail
b2Body()constructor
public function b2Body(bd:b2BodyDef, world:b2World)Parameters
bd:b2BodyDef
 
world:b2World
Method detail
Advance()method
public function Advance(t:Number):voidParameters
t:Number
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
IsConnected()method 
public function IsConnected(other:b2Body):BooleanParameters
other:b2Body

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
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.
SynchronizeShapes()method 
public function SynchronizeShapes():Boolean

Returns
Boolean
SynchronizeTransform()method 
public function SynchronizeTransform():void
WakeUp()method 
public function WakeUp():void

Wake up this body so it will begin simulating.