Hi all,
First off, I want to say that I just started using Box2D a few days ago and that it's really great!
I've got a little game built and it works well, but I noticed that the framerate really takes a hit if I disable debugDraw. This doesn't make any sense to me, because it should be doing less work. Here is what the code looks like:
If DEBUG is true, it runs fast, if it's false, it runs slow. And the DEBUG const is only read here.
What's even weirder is that if I keep debugDraw but I don't attach the Sprite it's drawing into to the stage, I still get that loss in performance.
Any ideas?
TIA,
-Elie
First off, I want to say that I just started using Box2D a few days ago and that it's really great!
I've got a little game built and it works well, but I noticed that the framerate really takes a hit if I disable debugDraw. This doesn't make any sense to me, because it should be doing less work. Here is what the code looks like:
Code:
if (DEBUG) {
// set up debug draw
var debugSprite = new Sprite();
stage.addChild(debugSprite);
var debugDraw:b2DebugDraw = new b2DebugDraw();
debugDraw.SetSprite(debugSprite);
debugDraw.SetDrawScale(BOX2D_RATIO);
debugDraw.SetFillAlpha(0.5);;
debugDraw.SetLineThickness(1.0);
debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit); // 0xFFFFFFFF;
world.SetDebugDraw(debugDraw);
}
// set up debug draw
var debugSprite = new Sprite();
stage.addChild(debugSprite);
var debugDraw:b2DebugDraw = new b2DebugDraw();
debugDraw.SetSprite(debugSprite);
debugDraw.SetDrawScale(BOX2D_RATIO);
debugDraw.SetFillAlpha(0.5);;
debugDraw.SetLineThickness(1.0);
debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit); // 0xFFFFFFFF;
world.SetDebugDraw(debugDraw);
}
If DEBUG is true, it runs fast, if it's false, it runs slow. And the DEBUG const is only read here.
What's even weirder is that if I keep debugDraw but I don't attach the Sprite it's drawing into to the stage, I still get that loss in performance.
Code:
if (DEBUG) {
// set up debug draw
var debugSprite = new Sprite();
//stage.addChild(debugSprite);
var debugDraw:b2DebugDraw = new b2DebugDraw();
debugDraw.SetSprite(debugSprite);
debugDraw.SetDrawScale(BOX2D_RATIO);
debugDraw.SetFillAlpha(0.5);;
debugDraw.SetLineThickness(1.0);
debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit); // 0xFFFFFFFF;
world.SetDebugDraw(debugDraw);
}
// set up debug draw
var debugSprite = new Sprite();
//stage.addChild(debugSprite);
var debugDraw:b2DebugDraw = new b2DebugDraw();
debugDraw.SetSprite(debugSprite);
debugDraw.SetDrawScale(BOX2D_RATIO);
debugDraw.SetFillAlpha(0.5);;
debugDraw.SetLineThickness(1.0);
debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit); // 0xFFFFFFFF;
world.SetDebugDraw(debugDraw);
}
Any ideas?
TIA,
-Elie