B2CREATEWORLD

This command will create a world with the specified properties.  The world acts as a "container" for the physics simulation, which cannot run unless it is in a world.

The left, top, right, and bottom parameters set the boundaries of the world in relation to the point (0,0) in the top-left corner of the screen.  Any body that moves past the world's boundaries is automatically [?deleted?].  It is usually better to have larger values for these parameters.  The GravX value controls the force of gravity on the X-axis.  A positive value pulls objects to the right.  The GravY value controls the force of gravity on the Y-axis.  A positive value pulls objects downwards.  A doSleep value of 1 will set objects to "sleep" when the forces acting on them are not great enough to overcome their inertia, preventing random twitching and increasing performance.

This command returns an integer "handle" for the created world.  It is strongly recommended that you save this value, as without you cannot manipulate the world's properties, create bodies in the world, or delete it.

Each world operates completely independently of every other world.

Syntax

IntegerHandle = b2CreateWorld(Left as Float, Top as Float, Right as Float, Bottom as Float, GravX as Float, GravY as Float, doSleep as Dword)

Related Information

BOX2D Commands Menu
Index