mirror of
https://github.com/jlengrand/korge-samples.git
synced 2026-03-10 08:31:18 +00:00
Rename sample -> samples to be consistent with korge-next
This commit is contained in:
1
samples/scenes/.gitignore
vendored
Normal file
1
samples/scenes/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
8
samples/scenes/build.gradle.kts
Normal file
8
samples/scenes/build.gradle.kts
Normal file
@@ -0,0 +1,8 @@
|
||||
import com.soywiz.korge.gradle.*
|
||||
|
||||
apply<KorgeGradlePlugin>()
|
||||
|
||||
korge {
|
||||
id = "com.soywiz.samples.scenes"
|
||||
targetDefault()
|
||||
}
|
||||
62
samples/scenes/src/commonMain/kotlin/main.kt
Normal file
62
samples/scenes/src/commonMain/kotlin/main.kt
Normal file
@@ -0,0 +1,62 @@
|
||||
import com.soywiz.korge.Korge
|
||||
import com.soywiz.korge.input.*
|
||||
import com.soywiz.korge.scene.Module
|
||||
import com.soywiz.korge.scene.Scene
|
||||
import com.soywiz.korge.view.Container
|
||||
import com.soywiz.korge.view.position
|
||||
import com.soywiz.korge.view.solidRect
|
||||
import com.soywiz.korge.view.text
|
||||
import com.soywiz.korim.color.Colors
|
||||
import com.soywiz.korinject.AsyncInjector
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
suspend fun main() = Korge(Korge.Config(module = MyModule))
|
||||
|
||||
object MyModule : Module() {
|
||||
override val mainScene: KClass<out Scene> = MyScene1::class
|
||||
|
||||
override suspend fun AsyncInjector.configure() {
|
||||
mapInstance(MyDependency("HELLO WORLD"))
|
||||
mapPrototype { MyScene1(get()) }
|
||||
mapPrototype { MyScene2(get()) }
|
||||
}
|
||||
}
|
||||
|
||||
class MyDependency(val value: String)
|
||||
|
||||
class MyScene1(val myDependency: MyDependency) : Scene() {
|
||||
override suspend fun Container.sceneInit() {
|
||||
text("MyScene1: ${myDependency.value}") { smoothing = false }
|
||||
solidRect(100, 100, Colors.RED) {
|
||||
position(200, 200)
|
||||
alpha = 0.7
|
||||
onOver { alpha = 1.0 }
|
||||
onOut { alpha = 0.7 }
|
||||
onClick {
|
||||
sceneContainer.changeTo<MyScene2>()
|
||||
}
|
||||
}
|
||||
solidRect(100, 100, Colors.BLUE) {
|
||||
position(250, 250)
|
||||
alpha = 0.7
|
||||
onOver { alpha = 1.0 }
|
||||
onOut { alpha = 0.7 }
|
||||
onClick {
|
||||
sceneContainer.changeTo<MyScene2>()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class MyScene2(val myDependency: MyDependency) : Scene() {
|
||||
override suspend fun Container.sceneInit() {
|
||||
text("MyScene2: ${myDependency.value}") { smoothing = false }
|
||||
solidRect(100, 100, Colors.BLUE) {
|
||||
position(200, 200)
|
||||
onClick {
|
||||
sceneContainer.changeTo<MyScene1>(MyDependency("From MyScene2"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
samples/scenes/src/commonTest/kotlin/test.kt
Normal file
7
samples/scenes/src/commonTest/kotlin/test.kt
Normal file
@@ -0,0 +1,7 @@
|
||||
import kotlin.test.*
|
||||
|
||||
class SimpleTest {
|
||||
@Test
|
||||
fun test() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user