support window resizing correctly

This commit is contained in:
2023-08-16 16:54:45 +10:00
parent 23eefd9408
commit 2c5547320d
3 changed files with 15 additions and 1 deletions

View File

@ -46,6 +46,12 @@ class Colin
cam.update()
}
fun resize(width: Int, height: Int)
{
cam.viewportWidth = width.toFloat()
cam.viewportHeight = height.toFloat()
}
fun update(deltaTime: Float)
{
val stick = Controllers.getCurrent()?.let { pad ->

View File

@ -116,6 +116,14 @@ class Game: ApplicationAdapter()
suzanneInstance.transform = Matrix4().translate(3.0f, 1.0f, -3.5f)
}
override fun resize(width: Int, height: Int)
{
colin.resize(width, height)
spriteBatch.projectionMatrix.setToOrtho2D(0.0f, 0.0f,
Gdx.graphics.getWidth().toFloat(),
Gdx.graphics.getHeight().toFloat());
}
private fun update(deltaTime: Float)
{
colin.update(deltaTime)

View File

@ -14,6 +14,6 @@ fun main()
//conf.useVsync(false)
//conf.setForegroundFPS(300)
conf.setWindowedMode(1280, 720)
conf.setResizable(false)
conf.setResizable(true)
Lwjgl3Application(Game(), conf)
}