More framerate improvement tricks - this was more than enough to offset the harm of the building and unit images, and went the other way!

The framerate started out before the image games as ~17-18 on the tested game, dropped to ~14-15 with the image changes, and is now at ~20-21~
This commit is contained in:
Yair Morgenstern
2020-11-19 23:04:09 +02:00
parent 2e668ddeb5
commit 223da7f531
3 changed files with 13 additions and 10 deletions

View File

@ -25,7 +25,6 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
val uncivGame = worldScreen.game
init {
isTransform = true // If this is not set then the city button won't scale!
touchable = Touchable.disabled
}

View File

@ -77,7 +77,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
}
val unitLayerGroup = UnitLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled }
val cityButtonLayerGroup = Group().apply { isTransform = true; setSize(groupSize, groupSize);
val cityButtonLayerGroup = Group().apply { setSize(groupSize, groupSize);
touchable = Touchable.childrenOnly; setOrigin(Align.center) }
val circleCrosshairFogLayerGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize) }

View File

@ -460,16 +460,20 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
worldScreen.shouldUpdate=true
}
override fun zoom(zoomScale:Float){
override fun zoom(zoomScale:Float) {
super.zoom(zoomScale)
val scale = 1/scaleX // don't use zoomScale itself, in case it was out of bounds and not applied
if(scale < 1 && scale > 0.5f)
for(tileGroup in tileGroups.values)
val scale = 1 / scaleX // don't use zoomScale itself, in case it was out of bounds and not applied
if (scale >= 1)
for (tileGroup in tileGroups.values)
tileGroup.cityButtonLayerGroup.isTransform = false // to save on rendering time to improve framerate
if (scale < 1 && scale > 0.5f)
for (tileGroup in tileGroups.values) {
tileGroup.cityButtonLayerGroup.isTransform = true
tileGroup.cityButtonLayerGroup.setScale(scale)
}
}
// For debugging purposes
override fun draw(batch: Batch?, parentAlpha: Float) {
super.draw(batch, parentAlpha)
}
override fun draw(batch: Batch?, parentAlpha: Float) { super.draw(batch, parentAlpha) }
override fun act(delta: Float) { super.act(delta) }
}