Why b2world::stet(dt:Number....), paramet dt can not vary???
Why b2world::stet(dt:Number....) dt can not vary??
Flashwhat do you men "it can't vary" ?
you can pass fixed time step which usually equals 1/fps and variable in which case you have to calculate delta time yourself on each ENTER_FRAME.
you can pass fixed time step which usually equals 1/fps and variable in which case you have to calculate delta time yourself on each ENTER_FRAME.
/// Take a time step. This performs collision detection, integration,
/// and constraint solution.
/// @param timeStep the amount of time to simulate, this should not vary.
/// @param iterations the number of iterations to be used by the constraint solver.
The commet of b2World.as
/// and constraint solution.
/// @param timeStep the amount of time to simulate, this should not vary.
/// @param iterations the number of iterations to be used by the constraint solver.
The commet of b2World.as
So, for example. My fps is 33.0,but I cannt modify the fps runtime???
I have tired some. It doest work.
eg.
I call _body.SetLinearVelocity(new b2Vec2(4 , 0 )) every frame
When dt is 1/30, my body moves 2.8 every frame.
But when dt is 1/60, my body move 1.7 every frame.
1.7 + 1.7 = 3.4 > 2.8;
How can I do??If I want to make my game time synchronize?
eg.
I call _body.SetLinearVelocity(new b2Vec2(4 , 0 )) every frame
When dt is 1/30, my body moves 2.8 every frame.
But when dt is 1/60, my body move 1.7 every frame.
1.7 + 1.7 = 3.4 > 2.8;
How can I do??If I want to make my game time synchronize?
pseudo code:
Code:
function onEnterFrame(){
now = getTimer();
deltaStep = (now-old)/1000; // now-old = delta time. varies depending on your frame rate. in ideal circumstances (now-old)/1000 = 1/framerate
//it's actually the time that passed since the last frame update
world.Step(deltaStep);
old = now;
}
now = getTimer();
deltaStep = (now-old)/1000; // now-old = delta time. varies depending on your frame rate. in ideal circumstances (now-old)/1000 = 1/framerate
//it's actually the time that passed since the last frame update
world.Step(deltaStep);
old = now;
}
Original thread: https://box2d.org/forum/viewtopic.php?t=5603