Fixed timer wrapping problem
This commit is contained in:
parent
f334272243
commit
a16f7c2268
|
@ -77,8 +77,16 @@ public class Timer {
|
||||||
* @return the time in seconds, as a float
|
* @return the time in seconds, as a float
|
||||||
*/
|
*/
|
||||||
public float getTime() {
|
public float getTime() {
|
||||||
if (!paused)
|
if (!paused) {
|
||||||
lastTime = currentTime - startTime;
|
if (currentTime > startTime) {
|
||||||
|
lastTime = currentTime - startTime;
|
||||||
|
} else {
|
||||||
|
// The timer seems to have wrapped round. We don't know
|
||||||
|
// when it wrapped round, so the only thing we can reasonably
|
||||||
|
// do is reset the starttime and have a "glitch"
|
||||||
|
startTime = currentTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (float) ((double) lastTime / (double) resolution);
|
return (float) ((double) lastTime / (double) resolution);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue