June 2015
Beginner
354 pages
8h 23m
English
Carry out the following steps to create a static ground:
box2dcargame.js JavaScript file.pxPerMeter variable in the file; this is the unit setting in the Box2D world:var pxPerMeter = 30; // 30 pixels = 1 meter
function createGround() { var bodyDef = new b2BodyDef; var fixDef = new b2FixtureDef; bodyDef.type = b2Body.b2_staticBody; bodyDef.position.x = 250/pxPerMeter; bodyDef.position.y = 370 /pxPerMeter; fixDef.shape = new b2PolygonShape(); fixDef.shape.SetAsBox(250/pxPerMeter, 25/pxPerMeter); fixDef.restitution = 0.4; // create the body from the definition. var body ...Read now
Unlock full access