what is the correct way to exit the game? I want t...
# korge
r
what is the correct way to exit the game? I want to add an exit button in my menu;
Copy code
var exitButton = textButton(256.0, 32.0) {
            text = "Exit Game"
            position(100, 400 + 32)
            onClick {
                  sceneContainer.changeToAsync<PlayScene>()
            }
            enable()
        }
1
r
I had actually read through that sample. Can't believe I missed that. 😑 Thanks.
n
Glad to help. Keep us posted if anything is unclear
r
semi related, 1. To use the screen dimensions in positioning my views, I am using
views.actualVirtualWidth
Is that correct?
Copy code
var exitButton = textButton(256.0, 32.0) {
            text = "Exit"
            position(views.actualVirtualWidth/2 - 128, 400 + 16)
            onClick {
                  views.gameWindow.close()
            }
            enable()
        }
2. How can i set the background color/image of a scene? I can change the bg of the entire game using `
Copy code
views.clearColor = Colors.DARKGREEN
but want to do so for a specific scene
d
You can use a docking component to attach a view or a container automatically in a way that works with resizing. https://github.com/korlibs/korge/blob/bc4cfa3914518e8588f1146eec6ea9bf76ca1095/korge/src/commonMain/kotlin/com/soywiz/korge/component/docking/DockingComponent.kt
Copy code
view.dockedTo(Anchor.TOP_RIGHT)
If you plan to dock, for example a menu with several views, you can use a fixedSize container with a specific size as the view that is being docked
r
Thanks!
👍 1