PackageBox2D.Dynamics
Classpublic class b2Body
Sourceb2Body.as

A rigid body.



Public Properties
 PropertyDefined by
  b2_dynamicBody : uint = 2
[static]
b2Body
  b2_kinematicBody : uint = 1
[static]
b2Body
  b2_staticBody : uint = 0
[static]
b2Body
Public Methods
 MethodDefined by
  
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 fixture and attach it to this body.
b2Body
  
CreateFixture2(shape:b2Shape, density:Number = 0.0):b2Fixture
Creates a fixture from a shape and attach it to this body.
b2Body
  
DestroyFixture(fixture:b2Fixture):void
Destroy a fixture.
b2Body
  
GetAngle():Number
Get the angle in radians.
b2Body
  
Get the angular damping of the body
b2Body
  
Get the angular velocity.
b2Body
  
Get a list of all contacts attached to this body.
b2Body
  
Get the list of all controllers attached to this body.
b2Body
  
Get the definition containing the body properties.
b2Body
  
Get the list of all fixtures attached to this body.
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 damping of the 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 mass data of the body.
b2Body
  
Get the next body in the world's body list.
b2Body
  
Get the world body origin position.
b2Body
  
Get the body transform for the body's origin.
b2Body
  
GetType():uint
Get the type of 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
  
IsActive():Boolean
Get the active state of the body.
b2Body
  
IsAwake():Boolean
Get the sleeping state of this body.
b2Body
  
IsBullet():Boolean
Is this body treated like a bullet for continuous collision detection?
b2Body
  
IsFixedRotation():Boolean
Does this body have fixed rotation?
b2Body
  
Is this body allowed to sleep?
b2Body
  
Merge(other:b2Body):void
Merges another body into this.
b2Body
  
This resets the mass properties to the sum of the mass properties of the fixtures.
b2Body
  
SetActive(flag:Boolean):void
Set the active state of the body.
b2Body
  
SetAngle(angle:Number):void
Set the world body angle
b2Body
  
SetAngularDamping(angularDamping:Number):void
Set the angular damping of the body.
b2Body
  
SetAngularVelocity(omega:Number):void
Set the angular velocity.
b2Body
  
SetAwake(flag:Boolean):void
Set the sleep state of the body.
b2Body
  
SetBullet(flag:Boolean):void
Should this body be treated like a bullet for continuous collision detection?
b2Body
  
SetFixedRotation(fixed:Boolean):void
Set this body to have fixed rotation.
b2Body
  
SetLinearDamping(linearDamping:Number):void
Set the linear damping of the body.
b2Body
  
Set the linear velocity of the center of mass.
b2Body
  
SetMassData(massData:b2MassData):void
Set the mass properties to override the mass properties of the fixtures Note that this changes the center of mass position.
b2Body
  
SetPosition(position:b2Vec2):void
Setthe world body origin position.
b2Body
  
SetPositionAndAngle(position:b2Vec2, angle:Number):void
Set the position of the body's origin and rotation (radians).
b2Body
  
SetSleepingAllowed(flag:Boolean):void
Is this body allowed to sleep
b2Body
  
Set the position of the body's origin and rotation (radians).
b2Body
  
SetType(type:uint):void
Set the type of this body.
b2Body
  
SetUserData(data:*):void
Set the user data.
b2Body
  
Split(callback:Function):b2Body
Splits a body into two, preserving dynamic properties
b2Body
Property detail
b2_dynamicBodyproperty
public static var b2_dynamicBody:uint = 2
b2_kinematicBodyproperty 
public static var b2_kinematicBody:uint = 1
b2_staticBodyproperty 
public static var b2_staticBody:uint = 0
Method detail
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.
CreateFixture()method 
public function CreateFixture(def:b2FixtureDef):b2Fixture

Creates a fixture and attach it to this body. Use this function if you need to set some fixture parameters, like friction. Otherwise you can create the fixture directly from a shape. If the density is non-zero, this function automatically updates the mass of the body. Contacts are not created until the next time step.

Warning: This function is locked during callbacks.

Parameters
def:b2FixtureDef — the fixture definition.

Returns
b2Fixture
CreateFixture2()method 
public function CreateFixture2(shape:b2Shape, density:Number = 0.0):b2Fixture

Creates a fixture from a shape and attach it to this body. This is a convenience function. Use b2FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. This function automatically updates the mass of the body.

Warning: This function is locked during callbacks.

Parameters
shape:b2Shape — the shape to be cloned.
 
density:Number (default = 0.0) — the shape density (set to zero for static bodies).

Returns
b2Fixture
DestroyFixture()method 
public function DestroyFixture(fixture:b2Fixture):void

Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All fixtures attached to a body are implicitly destroyed when the body is destroyed.

Warning: This function is locked during callbacks.

Parameters
fixture:b2Fixture — the fixture to be removed.
GetAngle()method 
public function GetAngle():Number

Get the angle in radians.

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

Get the angular damping of the body

Returns
Number
GetAngularVelocity()method 
public function GetAngularVelocity():Number

Get the angular velocity.

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

Get a list of all contacts attached to this body.

Returns
b2ContactEdge
GetControllerList()method 
public function GetControllerList():b2ControllerEdge

Get the list of all controllers attached to this body.

Returns
b2ControllerEdge
GetDefinition()method 
public function GetDefinition():b2BodyDef

Get the definition containing the body properties.

Note: This provides a feature specific to this port.

Returns
b2BodyDef
GetFixtureList()method 
public function GetFixtureList():b2Fixture

Get the list of all fixtures attached to this body.

Returns
b2Fixture
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
GetLinearDamping()method 
public function GetLinearDamping():Number

Get the linear damping of the body.

Returns
Number
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).
GetMassData()method 
public function GetMassData(data:b2MassData):void

Get the mass data of the body. The rotational inertial is relative to the center of mass.

Parameters
data:b2MassData
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.
GetTransform()method 
public function GetTransform():b2Transform

Get the body transform for the body's origin.

Returns
b2Transform — the world transform of the body's origin.
GetType()method 
public function GetType():uint

Get the type of this body.

Returns
uint — type enum as a uint
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.
IsActive()method 
public function IsActive():Boolean

Get the active state of the body.

Returns
Boolean — true if active.
IsAwake()method 
public function IsAwake():Boolean

Get the sleeping state of this body.

Returns
Boolean — true if body is sleeping
IsBullet()method 
public function IsBullet():Boolean

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

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

Does this body have fixed rotation?

Returns
Boolean — true means fixed rotation
IsSleepingAllowed()method 
public function IsSleepingAllowed():Boolean

Is this body allowed to sleep?

Returns
Boolean
Merge()method 
public function Merge(other:b2Body):void

Merges another body into this. Only fixtures, mass and velocity are effected, Other properties are ignored

Note: This provides a feature specific to this port.

Parameters
other:b2Body
ResetMassData()method 
public function ResetMassData():void

This resets the mass properties to the sum of the mass properties of the fixtures. This normally does not need to be called unless you called SetMassData to override the mass and later you want to reset the mass.

SetActive()method 
public function SetActive(flag:Boolean):void

Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a b2World object and remains in the body list.

Parameters
flag:Boolean
SetAngle()method 
public function SetAngle(angle:Number):void

Set the world body angle

Parameters
angle:Number — the new angle of the body.
SetAngularDamping()method 
public function SetAngularDamping(angularDamping:Number):void

Set the angular damping of the body.

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

Set the angular velocity.

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

Set the sleep state of the body. A sleeping body has vety low CPU cost.

Parameters
flag:Boolean — - set to true to put body to sleep, false to wake it
SetBullet()method 
public function SetBullet(flag:Boolean):void

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

Parameters
flag:Boolean
SetFixedRotation()method 
public function SetFixedRotation(fixed:Boolean):void

Set this body to have fixed rotation. This causes the mass to be reset.

Parameters
fixed:Boolean — - true means no rotation
SetLinearDamping()method 
public function SetLinearDamping(linearDamping:Number):void

Set the linear damping of the body.

Parameters
linearDamping:Number
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.
SetMassData()method 
public function SetMassData(massData:b2MassData):void

Set the mass properties to override the mass properties of the fixtures Note that this changes the center of mass position. Note that creating or destroying fixtures can also alter the mass. This function has no effect if the body isn't dynamic.

Warning: The supplied rotational inertia should be relative to the center of mass

Parameters
massData:b2MassData — the mass properties.
SetPosition()method 
public function SetPosition(position:b2Vec2):void

Setthe world body origin position.

Parameters
position:b2Vec2 — the new position of the body
SetPositionAndAngle()method 
public function SetPositionAndAngle(position:b2Vec2, angle:Number):void

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

Is this body allowed to sleep

Parameters
flag:Boolean
SetTransform()method 
public function SetTransform(xf:b2Transform):void

Set the position of the body's origin and rotation (radians). This breaks any contacts and wakes the other bodies. Note this is less efficient than the other overload - you should use that if the angle is available.

Parameters
xf:b2Transform — the transform of position and angle to set the bdoy to.
SetType()method 
public function SetType(type:uint):void

Set the type of this body. This may alter the mass and velocity

Parameters
type:uint — - enum stored as a static member of b2Body
SetUserData()method 
public function SetUserData(data:*):void

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

Parameters
data:*
Split()method 
public function Split(callback:Function):b2Body

Splits a body into two, preserving dynamic properties

Note: This provides a feature specific to this port.

Parameters
callback:Function — Called once per fixture, return true to move this fixture to the new body function Callback(fixture:b2Fixture):Boolean

Returns
b2Body — The newly created bodies