English 中文(简体)
Box2D in Flash runs quicker when drawing debug data than not
原标题:

I ve created a small game with Box2d for AS3 - I have sprites attached to the stage that take their position from the underlying Box2d world. These sprites are mostly PNGs.

When the game runs with DrawDebugData() bening called every update, it runs nice and smoothly. However when I comment this out, it runs choppily. In both cases all my sprites are being rendered. So it seems that it s running faster when it s drawing the debug data additionaly (i.e. my sprites are on the screen in both cases!)

What s going on? Does drawing the debug data flick some sort of render quick switch? If so, what s the switch!? I can t see it in the Box2D code.

function Update(e){
    m_world.Step(m_timeStep, m_velocityIterations, m_positionIterations);
    // draw debug?
    m_world.DrawDebugData();
    // with the above line in, I get 27fps, without it, I get 19fps.
    // that s the only change that s causing such a huge difference.
    doStuff();
}

Interestingly, If i set the debug draw scale to something different to my world scale, it slows down to 19fps. So there s something happening when it draws the boxes under my sprites causing it to run quicker..

Cheers,

Guy

问题回答
private var gravity:b2Vec2 = new b2Vec2(0, 7.8);
private var doSleep:Boolean = false;
private var iterations:int = 10;
private var timeStep:Number = 1/30;

can your share this settings with us? doSleep improves the performance a lot

I had the same problems when testing box2d last year. I set the alphafill and outline alpha to 0 of the debug draw :D or you can remove flags so it doesn t debug joints etc.

it s just a work around. I ll look into box2d now. If I find out a solution to get same performance w/o debugdraw I tell you.

Im using box2d 2.1a btw.





相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

Red5 Security Tutorial

I am looking for a step by step tutorial on securing Red5 from intrusion. This seems to be a question that comes up alot in a google search, but is never really answered in a way that makes sense to ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

visible property of DisplayObject

For example I have a hierarchy of movie clips. mc1 is a child of mc, and mc2 is a child of mc1. Turns out that when I set mc1.visible = false; mc2.visible stays true. Is that supposed to happen?...

热门标签