0 votes
76 views
asked in Box2D by (2.6k 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 by (8.2k 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);

}

Categories

...