Box2D::b2World - Manages all aspects of the simulation.
my $world = Box2D::b2World->new( $gravity, $doSleep );
The Box2D::b2World class contains the bodies and joints. It manages all aspects of the simulation and allows for asynchronous queries (like AABB queries and ray-casts). Much of your interactions with Box2D will be with a Box2D::b2World object.
Construct a world object.
Box2D::b2Vec2 $gravity - the world gravity vector.
bool $doSleep - improve performance by not simulating inactive bodies.
Returns a Box2D::b2World
Call this after you are done with time steps to clear the forces. You normally call this after each call to Step, unless you are performing sub-steps. By default, forces will be automatically cleared, so you don't need to call this function.
See also: SetAutoClearForces
Create a rigid body given a definition. No reference to the definition is retained.
Warning: This function is locked during callbacks.
Returns a Box2D::b2Body
Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding.
Returns a Box2D::b2Joint
Destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks.
Warning: This automatically deletes all associated shapes and joints. This function is locked during callbacks.
Get the global gravity vector.
Returns a Box2D::b2Vec2
Ray-cast the world for all fixtures in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the starting point.
Box2D::b2RayCastCallback $callback - a user implemented callback class.
Box2D::b2Vec2 $point1 - the ray starting point
Box2D::b2Vec2 $point2 - the ray ending point
Register a contact event listener. The listener is owned by you and must remain in scope.
Change the global gravity vector.
Take a time step. This performs collision detection, integration, and constraint solution.
float32 $timeStep - the amount of time to simulate, this should not vary.
int32 $velocityIterations - for the velocity constraint solver.
int32 $positionIterations - for the position constraint solver.
See "BUGS" in Box2D
See "AUTHORS" in Box2D
See "COPYRIGHT & LICENSE" in Box2D
To install Box2D, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.