var groundFixtureDef = new Box2D.b2FixtureDef();
var groundBodyDef = new Box2D.b2BodyDef();
var groundShape = new Box2D.b2PolygonShape();
groundShape.SetAsBox(CANVAS_WIDTH/2,2);
groundFixtureDef.set_density(0.5);
groundFixtureDef.set_friction(0.4);
groundFixtureDef.set_restitution(0.2);
groundFixtureDef.set_shape(groundShape);
groundBodyDef.set_type(Box2D.b2_staticBody);
groundBodyDef.set_position(CANVAS_WIDTH/2, 0);
world.CreateBody(groundBodyDef).CreateFixture(groundFixtureDef);
Initialized and set debug draw:
var shapeBit = 0x0001;
var debugDraw = new Box2D.JSDraw();
debugDraw.SetFlags(shapeBit);
//initialized all debug draw functions; not including here since the code is too long (DrawSegment, etc.)
//also created draw() function from html5canvas example
world.SetDebugDraw(debugDraw);
Everything else seems to work, but when calling world.DrawDebugData(), there is always an error:
Uncaught TypeError: Cannot read property '19952' of undefined
Has anyone encountered this before? Or is there something I missed in initialization? I just followed some of the code from the html5canvas example. Sorry, I'm not very familiar with this but I have been tracing the issue for days since the Box2D files are minified.
Initialized world:
Created sample ground body:
Initialized and set debug draw:
Everything else seems to work, but when calling world.DrawDebugData(), there is always an error:
Has anyone encountered this before? Or is there something I missed in initialization? I just followed some of the code from the html5canvas example. Sorry, I'm not very familiar with this but I have been tracing the issue for days since the Box2D files are minified.