Box2dWebBox2D.Dynamics.b2DebugDraw
の世界をレンダリングするために使用しています。キャンバスを移動体の中心に保つにはどうすればよいですか?
var debugDraw = new Box2D.Dynamics.b2DebugDraw();
debugDraw.SetSprite(document.getElementById("canvasElement").getContext("2d"));
debugDraw.SetDrawScale(30.0);
debugDraw.SetFillAlpha(0.3);
debugDraw.SetLineThickness(1.0);
debugDraw.SetFlags(Box2D.Dynamics.b2DebugDraw.e_shapeBit | Box2D.Dynamics.b2DebugDraw.e_jointBit);
world.SetDebugDraw(debugDraw);
シミュレーションを実行するループでは、次のようになります。
window.setInterval( function(){
_this.world.Step(
1 / 60 //frame-rate
, 10 //velocity iterations
, 10 //position iterations
);
_this.world.DrawDebugData();
_this.world.ClearForces();
}, 1000 / 60);