I have check delta value in render method in Screen class.. I saw it is not constant. Can any body tell where it come from and what it is? And does it differ in different sc
The deltaTime
has nothing to do with screen sizes. It is the amount of time the last frame took to be rendered. Rendered in case of LibGDX also includes all the logic you execute in your render()
method.
Usually you want a game to run at the same speed on different devices. If your render method looks something like this...
public void render(float deltaTime) {
float speed = 5f;
position = position + speed;
}
...then the position would change faster on fast devices and less fast on slow devices, just because the render method is called a different amount of times.
To overcome this issue, there is the deltaTime
which in case of LibGDX is in seconds. To let the position change at the same rate on different devices, you usually do it like this:
public void render(float deltaTime) {
float speedPerSecond = 5f;
position = position + (speedPerSecond * deltaTime);
}