Framework: LibGDX

IDE: Android Studio

Game based on Kilobolt tutorial

While debugging, the frame delta time i get using Gdx.graphics.getDeltaTime()continues to increment so when i stop debugging and return to application, everything is fast (it is related to runTime, so delta time too)

runTime is calculated in GameScreen class, which increments it with deltaTime and then passes it to GameWorld and GameRenderer methods calls.

How can i stop it while debugging?


2 Answers 2


The delta time is the time since the last frame. Ofc, when you are debbuging, a frame takes verry long, as you are stepping through the code. Therefore the delta time can become huge.
But keep in mind, that the delta time can become bigger then expected, even without debuging.
Slow devices, f.e., can result in bigger delta times. So instead of "stopping" delta time, when debuging (i don't guess that thats even possible), you should limit it generally.

Also you might consider using an accumulator:

private float accumulator = 0;

public void render(float deltaTime) {
    // fixed time step
    // max frame time to avoid spiral of death (on slow devices)
    float frameTime = Math.min(deltaTime, 0.25f);
    accumulator += frameTime;
    while (accumulator >= Constants.TIME_STEP) {
       accumulator -= Constants.TIME_STEP;

That means, that if delta is big, you take many little steps, instead of one big, and render the results then. This results in a more accuraate logic.
The limitation of the delta time is still needed, as on slow devices, a huge delta would result in many update-calls, which result in even bigger delta times and so on.

  • \$\begingroup\$ hey @Springrbua can you tell me where Constants.TIME_STEP comes from? when i add it to my code, it gives me an error saying that i have to import a class \$\endgroup\$ May 24, 2015 at 7:16
  • \$\begingroup\$ It is just an example, where Constants is an interface or class, which stores the public final float TIME_STEP. \$\endgroup\$
    – Robert P
    May 28, 2015 at 6:19

Just add a limit on the number of updates you can do between drawing, i.e. limit the accumulator.

If it will never catch up for more than a second for example, you'll never run into this issue.

Also keep in mind that this is essentially needed to avoid situations where you're never able to catch up again, which might cause your app I get stuck (time per update being longer than the time between updates).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .