June 2015
Beginner
354 pages
8h 23m
English
Carry out the following steps to draw the useful debug view:
box2dcargame.js JavaScript file:var shouldDrawDebug = false;
function showDebugDraw() {
shouldDrawDebug = true;
//setup debug draw
var debugDraw = new b2DebugDraw();
debugDraw.SetSprite(document.getElementById('game').getContext('2d'));
debugDraw.SetDrawScale(pxPerMeter);
debugDraw.SetFillAlpha(0.3);
debugDraw.SetLineThickness(1.0);
debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit);
carGame.world.SetDebugDraw(debugDraw);
carGame.world.DrawDebugData();
}showDebugDraw function call at the end of the initGame method:showDebugDraw();
Read now
Unlock full access