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.
Box2D::b2World
Construct a world object.
Parameters:
Box2D::b2Vec2 $gravity - the world gravity vector.
Box2D::b2Vec2
$gravity
bool $doSleep - improve performance by not simulating inactive bodies.
bool
$doSleep
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.
Box2D::b2BodyDef $def
Box2D::b2BodyDef
$def
Returns a Box2D::b2Body
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.
Box2D::b2JointDef $def
Box2D::b2JointDef
Returns a Box2D::b2Joint
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.
Box2D::b2Body $body
$body
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::b2RayCastCallback
$callback
Box2D::b2Vec2 $point1 - the ray starting point
$point1
Box2D::b2Vec2 $point2 - the ray ending point
$point2
Register a contact event listener. The listener is owned by you and must remain in scope.
Box2D::b2ContactListener $listener
Box2D::b2ContactListener
$listener
Change the global gravity vector.
Box2D::b2Vec2 $gravity
Take a time step. This performs collision detection, integration, and constraint solution.
float32 $timeStep - the amount of time to simulate, this should not vary.
float32
$timeStep
int32 $velocityIterations - for the velocity constraint solver.
int32
$velocityIterations
int32 $positionIterations - for the position constraint solver.
$positionIterations
Box2D
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.
cpanm
cpanm Box2D
CPAN shell
perl -MCPAN -e shell install Box2D
For more information on module installation, please visit the detailed CPAN module installation guide.