downsampling sorta works, ONLY WHEN (width or height % 4) is 0 or 1

This commit is contained in:
minjaesong
2017-07-05 16:03:50 +09:00
parent f676938176
commit 0e4dd79cc1
16 changed files with 114 additions and 95 deletions

View File

@@ -1,8 +1,8 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.TerrarumGDX
/**
@@ -11,7 +11,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
object DrawUtil {
fun drawCentered(batch: SpriteBatch, image: Texture, screenPosY: Int, ui: UICanvas? = null) {
val imageW = image.width
val targetW = if (ui == null) Gdx.graphics.width else ui.width
val targetW = if (ui == null) TerrarumGDX.WIDTH else ui.width
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
}