Look into using override fun resize and override fun create? method

This commit is contained in:
2026-03-11 13:00:17 +00:00
parent 4de5a8f88b
commit 1cc46a94fe

View File

@@ -46,17 +46,20 @@ class MainMenu : KtxScreen {
addActor(hostButton) addActor(hostButton)
addActor(joinButton) addActor(joinButton)
} }
val lobbyContainer = Container<Actor>(hostOrJoinVerticalGroup).apply { val lobbyContainer = Container<Actor>(hostOrJoinVerticalGroup)
table.add(this)
}
//region Play //region Play
val casualButton = TextButton("Casual", defaultTextButtonStyle).apply { val casualButton = TextButton("Casual", defaultTextButtonStyle)
table.row()
table.add(this)
}
//endregion //endregion
val everythingVerticalGroup = VerticalGroup().apply {
addActor(lobbyContainer)
addActor(casualButton)
table.add(this)
Gdx.app.log("MainMenu", stage.width.toString())
//Gdx.app.log("MainMenu", table.width.toString())
}
private fun update(delta: Float) { private fun update(delta: Float) {
if (hostButton.isPressed) { if (hostButton.isPressed) {
Gdx.app.log("MainMenu", "Host button pressed") Gdx.app.log("MainMenu", "Host button pressed")
@@ -78,6 +81,11 @@ class MainMenu : KtxScreen {
stage.draw() stage.draw()
} }
override fun resize(width: Int, height: Int) {
Gdx.app.log("MainMenu", "resize called! New width: $width, new height $height")
everythingVerticalGroup.setSize(width.toFloat(), height.toFloat())
}
override fun dispose() { override fun dispose() {
stage.dispose() stage.dispose()
} }