I'm running a simple Libgdx game using Box2D physic and i get different speed on different Android devices.
I believe that this is because timestep.
If I use 1 and 2 example i get different speed on different devices and the 3 example it works nice but on old devices (on my old smartphone Galaxy Wonder) lose fps and is unplayable
1)
world.step(1f/60f, 6, 2);
2)
static final float STEP_TIME = 1f/60f;
float accumulator = 0;
private void stepWorld() {
float delta = Gdx.graphics.getDeltaTime();
accumulator += Math.min(delta, 0.25f);
if (accumulator >= STEP_TIME) {
accumulator -= STEP_TIME;
world.step(STEP_TIME, 6, 2);
}
}
3)
world.step(Gdx.graphics.getDeltaTime(), 6, 2);
There is an other way how to get the same speed?
while (accumulator >= STEP_TIME)
, notif
. Try changing that and report back. \$\endgroup\$