Smoother map panning

This commit is contained in:
Yair Morgenstern 2021-01-25 19:23:48 +02:00
parent 93bdb137f9
commit 48f68c6bd0

View File

@ -183,7 +183,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
object : InputListener() {
private val pressedKeys = mutableSetOf<Int>()
private var infiniteAction: RepeatAction? = null
private val amountToMove = 30 / mapHolder.scaleX
private val amountToMove = 6 / mapHolder.scaleX
private val ALLOWED_KEYS = setOf(Input.Keys.W, Input.Keys.S, Input.Keys.A, Input.Keys.D,
Input.Keys.UP, Input.Keys.DOWN, Input.Keys.LEFT, Input.Keys.RIGHT)
@ -194,7 +194,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
pressedKeys.add(keycode)
if (infiniteAction == null) {
// create a copy of the action, because removeAction() will destroy this instance
infiniteAction = Actions.forever(Actions.delay(0.05f, Actions.run { whileKeyPressedLoop() }))
infiniteAction = Actions.forever(Actions.delay(0.01f, Actions.run { whileKeyPressedLoop() }))
mapHolder.addAction(infiniteAction)
}
return true