Sample code for physics world corner in java script?

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

  Have create the physics world but the project is always going down. can you please provide the code for physics world corner in java script?

1 Answer

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

Hi

The ground is a rectangular object, that stays fixed at a place and serves as a ground where other things can fall.

Sample code to create the physics world corner - ground 

function createGround(world){

    var bodyDef = new b2BodyDef();

    fixDef = new b2FixtureDef;

    fixDef.density = 1.0;

    fixDef.friction = 1.0;

    fixDef.restitution = 0.5;

 fixDef.shape = new b2PolygonShape;

   fixDef.shape.SetAsBox(4.00 , .30);

    bodyDef.position.Set(4.10 , 4.70);

    return world.CreateBody(bodyDef).CreateFixture(fixDef);

}

...