How to Crete basics Physics world in javascript?

0 votes
43 views
asked May 3 in Box2D by codeg (2,600 points)
Hi All

   How to Crete basics Physics world in javascript and can you please provide the sample code.

1 Answer

0 votes
answered May 3 by admin (8,115 points)

Hi 

The b2World is a Box2d world, where objects exist and interact with each other. The gravity parameter is a vector which indicates the force magnitude and direction.

function createWorld(){

    //Gravity vector x, y - 10 m/s2 - thats earth!!

    var gravity = new b2Vec2(0, -10);

   world = new b2World( gravity , true );

    createGround(world);

     return world;

}  

...