mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
LibGDX, here I am.
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Image
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-08-04.
|
||||
*/
|
||||
object DrawUtil {
|
||||
fun drawCentered(g: Graphics, image: Image, screenPosY: Int, ui: UICanvas? = null) {
|
||||
fun drawCentered(batch: SpriteBatch, image: Texture, screenPosY: Int, ui: UICanvas? = null) {
|
||||
val imageW = image.width
|
||||
val targetW = if (ui == null) Terrarum.WIDTH else ui.width
|
||||
val targetW = if (ui == null) Gdx.graphics.width else ui.width
|
||||
|
||||
g.drawImage(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
|
||||
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
|
||||
}
|
||||
|
||||
fun drawCentered(g: Graphics, image: Image, screenPosY: Int, targetW: Int, offsetX: Int = 0, offsetY: Int = 0) {
|
||||
fun drawCentered(batch: SpriteBatch, image: Texture, screenPosY: Int, targetW: Int, offsetX: Int = 0, offsetY: Int = 0) {
|
||||
val imageW = image.width
|
||||
g.drawImage(image, targetW.minus(imageW).ushr(1).toFloat() + offsetX, screenPosY.toFloat() + offsetY)
|
||||
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat() + offsetX, screenPosY.toFloat() + offsetY)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user