| Package | Box2D.Dynamics |
| Class | public class b2World |
| Source | b2World.as |
| Method | Defined by | ||
|---|---|---|---|
|
| b2World | ||
|
Create a rigid body given a definition.
| b2World | ||
|
Create a joint to constrain bodies together.
| b2World | ||
|
DestroyBody(b:b2Body):void
Destroy a rigid body given a definition.
| b2World | ||
|
DestroyJoint(j:b2Joint):void
Destroy a joint.
| b2World | ||
|
GetBodyCount():int
Get the number of bodies.
| b2World | ||
|
Get the world body list.
| b2World | ||
|
GetContactCount():int
Get the number of contacts (each may have 0 or more contact points).
| b2World | ||
|
Get the global gravity vector.
| b2World | ||
|
The world provides a single static ground body with no collision shapes.
| b2World | ||
|
GetJointCount():int
Get the number of joints.
| b2World | ||
|
Get the world joint list.
| b2World | ||
|
GetPairCount():int
Get the number of broad-phase pairs.
| b2World | ||
|
GetProxyCount():int
Get the number of broad-phase proxies.
| b2World | ||
|
Check if the AABB is within the broadphase limits.
| b2World | ||
|
Query the world for all shapes that potentially overlap the
provided AABB.
| b2World | ||
|
Query the world for all shapes that intersect a given segment.
| b2World | ||
|
Performs a raycast as with Raycast, finding the first intersecting shape.
| b2World | ||
|
Re-filter a shape.
| b2World | ||
|
SetBoundaryListener(listener:b2BoundaryListener):void
Register a broad-phase boundary listener.
| b2World | ||
|
SetContactFilter(filter:b2ContactFilter):void
Register a contact filter to provide specific control over collision.
| b2World | ||
|
SetContactListener(listener:b2ContactListener):void
Register a contact event listener
| b2World | ||
|
SetContinuousPhysics(flag:Boolean):void
Enable/disable continuous physics.
| b2World | ||
|
SetDebugDraw(debugDraw:b2DebugDraw):void
Register a routine for debug drawing.
| b2World | ||
|
SetDestructionListener(listener:b2DestructionListener):void
Destruct the world.
| b2World | ||
|
SetGravity(gravity:b2Vec2):void
Change the global gravity vector.
| b2World | ||
|
SetWarmStarting(flag:Boolean):void
Enable/disable warm starting.
| b2World | ||
|
Step(dt:Number, velocityIterations:int, positionIterations:int):void
Take a time step.
| b2World | ||
|
Validate():void
Perform validation of internal data structures.
| b2World | ||
| b2World | () | constructor |
public function b2World(worldAABB:b2AABB, gravity:b2Vec2, doSleep:Boolean)Parameters
worldAABB:b2AABB — a bounding box that completely encompasses all your shapes.
|
|
gravity:b2Vec2 — the world gravity vector.
|
|
doSleep:Boolean — improve performance by not simulating inactive bodies.
|
| CreateBody | () | method |
public function CreateBody(def:b2BodyDef):b2BodyCreate a rigid body given a definition. No reference to the definition is retained.
Warning: This function is locked during callbacks.
Parametersdef:b2BodyDef |
b2Body |
| CreateJoint | () | method |
public function CreateJoint(def:b2JointDef):b2JointCreate a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding.
Warning: This function is locked during callbacks.
Parametersdef:b2JointDef |
b2Joint |
| DestroyBody | () | method |
public function DestroyBody(b:b2Body):voidDestroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks.
Warning: This function is locked during callbacks.
Parametersb:b2Body |
| DestroyJoint | () | method |
public function DestroyJoint(j:b2Joint):voidDestroy a joint. This may cause the connected bodies to begin colliding.
Warning: This function is locked during callbacks.
Parametersj:b2Joint |
| GetBodyCount | () | method |
public function GetBodyCount():intGet the number of bodies.
Returnsint |
| GetBodyList | () | method |
public function GetBodyList():b2BodyGet the world body list. With the returned body, use b2Body::GetNext to get the next body in the world list. A NULL body indicates the end of the list.
Returnsb2Body —
the head of the world body list.
|
| GetContactCount | () | method |
public function GetContactCount():intGet the number of contacts (each may have 0 or more contact points).
Returnsint |
| GetGravity | () | method |
| GetGroundBody | () | method |
public function GetGroundBody():b2BodyThe world provides a single static ground body with no collision shapes. You can use this to simplify the creation of joints and static shapes.
Returnsb2Body |
| GetJointCount | () | method |
public function GetJointCount():intGet the number of joints.
Returnsint |
| GetJointList | () | method |
public function GetJointList():b2JointGet the world joint list. With the returned joint, use b2Joint::GetNext to get the next joint in the world list. A NULL joint indicates the end of the list.
Returnsb2Joint —
the head of the world joint list.
|
| GetPairCount | () | method |
public function GetPairCount():intGet the number of broad-phase pairs.
Returnsint |
| GetProxyCount | () | method |
public function GetProxyCount():intGet the number of broad-phase proxies.
Returnsint |
| InRange | () | method |
public function InRange(aabb:b2AABB):BooleanCheck if the AABB is within the broadphase limits.
Parametersaabb:b2AABB |
Boolean |
| Query | () | method |
public function Query(aabb:b2AABB, shapes:Array, maxCount:int):intQuery the world for all shapes that potentially overlap the provided AABB. You provide a shape pointer buffer of specified size. The number of shapes found is returned.
Parametersaabb:b2AABB — the query box.
|
|
shapes:Array — a user allocated shape pointer array of size maxCount (or greater).
|
|
maxCount:int — the capacity of the shapes array.
|
int — the number of shapes found in aabb.
|
| Raycast | () | method |
public function Raycast(segment:b2Segment, shapes:Array, maxCount:int, solidShapes:Boolean, userData:*):intQuery the world for all shapes that intersect a given segment. You provide a shap pointer buffer of specified size. The number of shapes found is returned, and the buffer is filled in order of intersection
Parameterssegment:b2Segment — defines the begin and end point of the ray cast, from p1 to p2.
Use b2Segment.Extend to create (semi-)infinite rays
|
|
shapes:Array — a user allocated shape pointer array of size maxCount (or greater).
|
|
maxCount:int — the capacity of the shapes array
|
|
solidShapes:Boolean — determines if shapes that the ray starts in are counted as hits.
|
|
userData:* — passed through the world's contact filter, with method RayCollide. This can be used to filter valid shapes
|
int — the number of shapes found.
|
See also
| RaycastOne | () | method |
public function RaycastOne(segment:b2Segment, lambda:Array, normal:b2Vec2, solidShapes:Boolean, userData:*):b2ShapePerforms a raycast as with Raycast, finding the first intersecting shape.
Parameterssegment:b2Segment — defines the begin and end point of the ray cast, from p1 to p2.
Use b2Segment.Extend to create (semi-)infinite rays
|
|
lambda:Array — returns the hit fraction. You can use this to compute the contact point
p = (1 - lambda) segment.p1 + lambda segment.p2.
lambda should be an array with one member. After calling TestSegment, you can retrieve the output value with
lambda[0].
|
|
normal:b2Vec2 — returns the normal at the contact point. If there is no intersection, the normal
is not set.
|
|
solidShapes:Boolean — determines if shapes that the ray starts in are counted as hits.
|
|
userData:* — passed through the world's contact filter, with method RayCollide. This can be used to filter valid shapes.
|
b2Shape —
the colliding shape shape, or null if not found.
|
See also
| Refilter | () | method |
public function Refilter(shape:b2Shape):voidRe-filter a shape. This re-runs contact filtering on a shape.
Parametersshape:b2Shape |
| SetBoundaryListener | () | method |
public function SetBoundaryListener(listener:b2BoundaryListener):voidRegister a broad-phase boundary listener.
Parameterslistener:b2BoundaryListener |
| SetContactFilter | () | method |
public function SetContactFilter(filter:b2ContactFilter):voidRegister a contact filter to provide specific control over collision. Otherwise the default filter is used (b2_defaultFilter).
Parametersfilter:b2ContactFilter |
| SetContactListener | () | method |
public function SetContactListener(listener:b2ContactListener):voidRegister a contact event listener
Parameterslistener:b2ContactListener |
| SetContinuousPhysics | () | method |
public function SetContinuousPhysics(flag:Boolean):voidEnable/disable continuous physics. For testing.
Parametersflag:Boolean |
| SetDebugDraw | () | method |
public function SetDebugDraw(debugDraw:b2DebugDraw):voidRegister a routine for debug drawing. The debug draw functions are called inside the b2World::Step method, so make sure your renderer is ready to consume draw commands when you call Step().
ParametersdebugDraw:b2DebugDraw |
| SetDestructionListener | () | method |
public function SetDestructionListener(listener:b2DestructionListener):voidDestruct the world. All physics entities are destroyed and all heap memory is released.
Parameterslistener:b2DestructionListener |
| SetGravity | () | method |
public function SetGravity(gravity:b2Vec2):voidChange the global gravity vector.
Parametersgravity:b2Vec2 |
| SetWarmStarting | () | method |
public function SetWarmStarting(flag:Boolean):voidEnable/disable warm starting. For testing.
Parametersflag:Boolean |
| Step | () | method |
public function Step(dt:Number, velocityIterations:int, positionIterations:int):voidTake a time step. This performs collision detection, integration, and constraint solution.
Parametersdt:Number — the amount of time to simulate, this should not vary.
|
|
velocityIterations:int — for the velocity constraint solver.
|
|
positionIterations:int — for the position constraint solver.
|
| Validate | () | method |
public function Validate():voidPerform validation of internal data structures.