问题
I create a box2d world, put some objects on the screen with different properties like rotation, restitution ,density. And then I start the application. Is it possible to fast forward the simulation so that I can see the result quickly? By result I mean the final state of the world objects. Just like a video clip.
回答1:
Thanks to Andrew I found that if I run the Step function multiple times, I can get the fast forwarded simulation. Here's just a little code that I guess anybody could write:
-(void)simulateWithFastForwardRate:(int)ffRate timeStep:(float32)timeStep
velocity:(int)velIters
andPositionIterations:(int)posIters{
for(int i=0;i<ffRate;i++){
_world->Step(timeStep,velIters,posIters);
}
}
Just run the above method passing it the fast forward rate, velocity and position iterations.
来源:https://stackoverflow.com/questions/15208549/is-it-possible-to-fast-forward-simulation-in-box2d