Make map symmetrical if it's not wrapped (#4461)

This commit is contained in:
lishaoxia1985
2021-07-11 15:51:57 +08:00
committed by GitHub
parent 5a0eb11bd0
commit 4c9e15c0ea
3 changed files with 8 additions and 9 deletions

View File

@ -120,9 +120,11 @@ class TileGroupMap<T: TileGroup>(tileGroups: Collection<T>, private val leftAndR
// there are tiles "below the zero",
// so we zero out the starting position of the whole board so they will be displayed as well
// The width has to be lowered by groupSize because wrapped maps are missing a tile on the right.
// Map's width is reduced by groupSize if it is wrapped, because wrapped map will miss a tile on the right.
// This ensures that wrapped maps have a smooth transition.
setSize(topX - bottomX + leftAndRightPadding * 2 - groupSize, topY - bottomY + topAndBottomPadding * 2)
// If map is not wrapped, Map's width doesn't need to be reduce by groupSize
if (worldWrap) setSize(topX - bottomX + leftAndRightPadding * 2 - groupSize, topY - bottomY + topAndBottomPadding * 2)
else setSize(topX - bottomX + leftAndRightPadding * 2, topY - bottomY + topAndBottomPadding * 2)
}
/**

View File

@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Screen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.scenes.scene2d.Stage
@ -96,7 +95,6 @@ open class CameraStageBaseScreen : Screen {
skin.get(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts.font.apply { data.setScale(20 / Fonts.ORIGINAL_FONT_SIZE) }
skin
}
internal var batch: Batch = SpriteBatch()
}
fun onBackButtonClicked(action: () -> Unit) {

View File

@ -11,10 +11,6 @@ open class ZoomableScrollPane: ScrollPane(null) {
var continuousScrollingX = false
init{
// Remove the existing inputListener
// which defines that mouse scroll = vertical movement
val zoomListener = listeners.last { it is InputListener && it !in captureListeners }
removeListener(zoomListener)
addZoomListeners()
}
@ -30,7 +26,10 @@ open class ZoomableScrollPane: ScrollPane(null) {
}
private fun addZoomListeners() {
// At first, Remove the existing inputListener
// which defines that mouse scroll = vertical movement
val zoomListener = listeners.last { it is InputListener && it !in captureListeners }
removeListener(zoomListener)
addListener(object : InputListener() {
override fun scrolled(event: InputEvent?, x: Float, y: Float, amountX: Float, amountY: Float): Boolean {
if (amountX > 0 || amountY > 0) zoomOut()