Box2d performance question

Hi everyone,

I have problem, that I can't solve for about one week now...
I have swf with box2d platform game. Stage size is about 500x400. Runs perfect, performance is ok.
When I load this swf to flas website, with size about 1000 x 800 it slows down extremely..🙁
The game runs extremely slow, takes about 85% CPU... Please help, what could be the solution for this?
Unless you're using Box2D's debug draw, I don't think the lag is caused by Box2D. How is the screen being drawn? Do you move sprites around, or is it being redrawn every frame? What is the scale mode of the stage?

To check if it's Box2D's fault, you should use flash.utils.getTimer() before and after the world.Step(), get the difference between the values, and trace it. Something like this:

Code: Select all

var beforeStep:int = flash.utils.getTimer(); //this is in milliseconds
world.Step(dt,velIter,posIter);
trace("step duration: " + (flash.utils.getTimer() - beforeStep));


If the traced time is higher than your fixed time step that you use to update the world, then it may be a problem that's related to the physics side of Box2D (the bodies, the fixtures, the collisions, or something). If you're using Box2D's debug draw, you should try to do the same thing as above and see if the drawing takes a long time.
Thank you for your reply. I will try, page is full screen, and I thought it can cause the problem. But I noticed, that whenever I load game to swf with bigger stage, it always slows down :/.

Original thread: https://box2d.org/forum/viewtopic.php?t=8581