Different Box2D body speeds on different devices

My problem is documented in this: Video

The background speed and animation run at the same speed, while the items thrown by this black guy move slower on a white device ... Well yes, the white phone is older, but that's not a problem I think because I tested my app on a phone with almost the same hardware as the black phone and had the same problem. Can anyone help me understand why this is happening ...?

my step is world.step (1 / 60f, 6, 2) ;. Dimensions are divided by PPM 100.

Thank!

+3


source to share


1 answer


Libgdx is always faster than anything the device can handle (with the exception of the desktop where you can dock it up to 60 times per second).

Hardware isn't always the difference. Android devices have frames per second, for example my Galaxy Ace has an FPS cap of 90. And some even newer and more powerful devices may have 60 or even 50. So your app will update faster in my galactic ace than any from these other devices.

You can use this technique to close it yourself:

You have two fields.



public static final float FPSCAP = 1/60F;
private float accumulator = 0;

      

And in your render method.

accumulator+=delta;
while(accumulator>FPSCAP){
   world.step(FPSCAP, 6, 2);
   accumulator-=FPSCAP;
}

      

+2


source







All Articles