Gdx.graphics.getDeltaTime() - time between the beginning of the previous and the beginning of the current render() call. This is also the value that you get in the Screen#render() method. It. No black magic or anything else. It just takes the current time and subtracts the previous time from it. unit of this value is seconds. Please note that it does not add up to one.
So, if the method was called the previous time, it was at 6:51:30.0159512 pm , and the current time it is called is at 6:51:30.0324858 pm , then the difference is 0.0165346 seconds .
Speed ββ(speed) is measured in units per second, for example meter per second or short: m/s . If your car travels 360 m/s , and the elapsed time is 0.0165346 s , then the distance you covered during this time is 0.0165346*360 s*m/s => 5.952456 m , so itβs almost 6 meters.
Please note that this is basic physics, it is not specific to libGDX. If you find it difficult to understand, you can read on velocity .
To answer your bottom questions, I think it's about splitting the rendering method into a separate update method.
- The code does not mean anything.
- There is nothing behind the code.
- Using clearly defined short methods is usually good practice. Read: Separation of Problems.
- I donβt know what you mean by "frame", but the speed is multiplied by the time to get the distance
Xoppa source share