Last active
December 29, 2025 12:53
-
-
Save marenovakovic/a3abd2f0ed26f3d3c7beee2bd03598ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| suspend fun main() = Korge( | |
| windowSize = Size(640.0, 320.0), | |
| backgroundColor = Colors.WHITE, | |
| ) { | |
| val sceneContainer = sceneContainer() | |
| sceneContainer.changeTo { | |
| RpgScene() | |
| } | |
| } | |
| private class RpgScene : Scene() { | |
| override suspend fun SContainer.sceneMain() { | |
| val idle = SpriteAnimation( | |
| spriteMap = resourcesVfs["warrior/idle.png"].readBitmap(), | |
| spriteWidth = 130, | |
| spriteHeight = 145, | |
| columns = 8, | |
| rows = 1, | |
| ) | |
| val attack = SpriteAnimation( | |
| spriteMap = resourcesVfs["warrior/attack.png"].readBitmap(), | |
| spriteWidth = 130, | |
| spriteHeight = 145, | |
| columns = 10, | |
| rows = 1, | |
| ) | |
| val death = SpriteAnimation( | |
| spriteMap = resourcesVfs["warrior/death.png"].readBitmap(), | |
| spriteWidth = 130, | |
| spriteHeight = 145, | |
| columns = 7, | |
| rows = 1, | |
| ) | |
| val character = sprite(idle) | |
| character.playAnimationLooped(spriteDisplayTime = 200.milliseconds) | |
| character.onAnimationCompleted({ | |
| character.playAnimationLooped(idle, spriteDisplayTime = 200.milliseconds) | |
| }) | |
| uiHorizontalStack(padding = 4f) { | |
| uiButton("Attack") { | |
| onPress({ character.playAnimation(attack) }) | |
| } | |
| uiButton("Death") { | |
| onPress({ character.playAnimation(death) }) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment