module UI now has margin; game update will drop consecutive updates if its try count is exhausted (reduced lag after window move/resize)

This commit is contained in:
minjaesong
2017-09-15 01:40:12 +09:00
parent 553816e8c4
commit d3b54ae300
6 changed files with 31 additions and 5 deletions

View File

@@ -394,9 +394,15 @@ class Ingame(val batch: SpriteBatch) : Screen {
///////////////
private class ThreadIngameUpdate(val ingame: Ingame): Runnable {
override fun run() {
var updateTries = 0
while (ingame.updateDeltaCounter >= ingame.updateRate) {
ingame.updateGame(Terrarum.deltaTime)
ingame.updateDeltaCounter -= ingame.updateRate
updateTries++
if (updateTries >= Terrarum.UPDATE_CATCHUP_MAX_TRIES) {
break
}
}
}
}
@@ -451,9 +457,15 @@ class Ingame(val batch: SpriteBatch) : Screen {
// else, NOP;
}
else {
var updateTries = 0
while (updateDeltaCounter >= updateRate) {
updateGame(delta)
updateDeltaCounter -= updateRate
updateTries++
if (updateTries >= Terrarum.UPDATE_CATCHUP_MAX_TRIES) {
break
}
}
}