Open FlixelCommunityBot opened 12 years ago
Comment by: avoxgames
There is a danger that at the first time a call of the function step() may be skipped (when you set high framerate, for example FlxG.flashFramerate = 90) and _state.draw() will fail.
For anyone digging into this issue, I have found these two articles which should help:
I have been trying to dig into this issue myself, and although I now understand the idea behind the deterministic delta-tee, I'm having some difficulty juggling those variables in my head, but I think I have a solution.
This is how the original code looks (with Krix's addition which seems to also be recommended by the article mentioned earlier):
_accumulator += elapsedMS;
if(_accumulator > _maxAccumulation)
_accumulator = _maxAccumulation;
while(_accumulator >= _step)
{
step();
_accumulator -= _step;
}
And this is my idea, which would ensure that step()
is always run at least once, whether the framereate is high or low, or is catching up after some lag.
_accumulator += elapsedMS;
if(_accumulator > _maxAccumulation)
_accumulator = _maxAccumulation;
do
{
step();
_accumulator -= _step;
} while(_accumulator >= _step); // <-- would this now be "greater than" or "greater than or equals"?
However, I'm very uncertain whether or not I'm thinking along the right lines, so I would like someone else to check me on this.
Issue #200 by: ghost
https://github.com/krix/flixel/commit/7fbc822359dfdfd6d74d9b9eaf86e0699c1cb0da
More explanation: http://forums.flixel.org/index.php/topic,5072.0.html