How to Crete basics Physics world in javascript?

0 votes
60 views
asked May 3, 2017 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, 2017 by admin (8,135 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;

}  

...