HTML and CSS Reference
In-Depth Information
Creating a Box2dWeb World
Next we add the code to initialize the world. The variables created in the following code are
shortcuts to the objects in Box2dWeb. They have shorter names make it much easier to define
new objects in code. Not all the objects in Box2dWeb are represented here, so if you need a
different one (such as a joint with b2JointDef), you will need to define a new shortcut (or just
use the full object path name).
var
b2Vec2 = Box2D . Common . Math . b2Vec2
,
b2BodyDef = Box2D . Dynamics . b2BodyDef
,
b2Body = Box2D . Dynamics . b2Body
,
b2FixtureDef = Box2D . Dynamics . b2FixtureDef
,
b2World = Box2D . Dynamics . b2World
,
b2PolygonShape = Box2D . Collision . Shapes . b2PolygonShape
,
b2CircleShape = Box2D . Collision . Shapes . b2CircleShape
,
b2DebugDraw = Box2D . Dynamics . b2DebugDraw ;
Now you create your world object. This will define your physics world. b2Vec() is a Box2D
object that accepts two parameters: x-axis gravity and y-axis gravity. The second parameter is
doSleep , which improves performance by not simulating inactive bodies if set to true.
var
var world = new
new b2World ( new
new b2Vec2 ( 0 , 10 ), true
true );
Search WWH ::




Custom Search