Create project to learn how to use scene 2d
This commit is contained in:
46
uitest/core/build.gradle
Normal file
46
uitest/core/build.gradle
Normal file
@@ -0,0 +1,46 @@
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
eclipse.project.name = appName + '-core'
|
||||
|
||||
dependencies {
|
||||
api "com.badlogicgames.ashley:ashley:$ashleyVersion"
|
||||
api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
|
||||
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
api "io.github.libktx:ktx-actors:$ktxVersion"
|
||||
api "io.github.libktx:ktx-ai:$ktxVersion"
|
||||
api "io.github.libktx:ktx-app:$ktxVersion"
|
||||
api "io.github.libktx:ktx-artemis:$ktxVersion"
|
||||
api "io.github.libktx:ktx-ashley:$ktxVersion"
|
||||
api "io.github.libktx:ktx-assets-async:$ktxVersion"
|
||||
api "io.github.libktx:ktx-assets:$ktxVersion"
|
||||
api "io.github.libktx:ktx-async:$ktxVersion"
|
||||
api "io.github.libktx:ktx-box2d:$ktxVersion"
|
||||
api "io.github.libktx:ktx-collections:$ktxVersion"
|
||||
api "io.github.libktx:ktx-freetype-async:$ktxVersion"
|
||||
api "io.github.libktx:ktx-freetype:$ktxVersion"
|
||||
api "io.github.libktx:ktx-graphics:$ktxVersion"
|
||||
api "io.github.libktx:ktx-i18n:$ktxVersion"
|
||||
api "io.github.libktx:ktx-inject:$ktxVersion"
|
||||
api "io.github.libktx:ktx-json:$ktxVersion"
|
||||
api "io.github.libktx:ktx-log:$ktxVersion"
|
||||
api "io.github.libktx:ktx-math:$ktxVersion"
|
||||
api "io.github.libktx:ktx-preferences:$ktxVersion"
|
||||
api "io.github.libktx:ktx-reflect:$ktxVersion"
|
||||
api "io.github.libktx:ktx-scene2d:$ktxVersion"
|
||||
api "io.github.libktx:ktx-style:$ktxVersion"
|
||||
api "io.github.libktx:ktx-tiled:$ktxVersion"
|
||||
api "io.github.libktx:ktx-vis-style:$ktxVersion"
|
||||
api "io.github.libktx:ktx-vis:$ktxVersion"
|
||||
api "net.onedaybeard.artemis:artemis-odb:$artemisOdbVersion"
|
||||
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion"
|
||||
|
||||
if(enableGraalNative == 'true') {
|
||||
implementation "io.github.berstanio:gdx-svmhelper-annotations:$graalHelperVersion"
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
73
uitest/core/src/main/kotlin/com/iofferyoutea/uitest/Main.kt
Normal file
73
uitest/core/src/main/kotlin/com/iofferyoutea/uitest/Main.kt
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.iofferyoutea.uitest
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||
import ktx.app.KtxGame
|
||||
import ktx.app.KtxScreen
|
||||
import ktx.app.clearScreen
|
||||
import ktx.async.KtxAsync
|
||||
import org.w3c.dom.Text
|
||||
|
||||
class Main : KtxGame<KtxScreen>() {
|
||||
override fun create() {
|
||||
KtxAsync.initiate()
|
||||
|
||||
addScreen(FirstScreen())
|
||||
setScreen<FirstScreen>()
|
||||
}
|
||||
}
|
||||
|
||||
class FirstScreen : KtxScreen {
|
||||
val stage = Stage()
|
||||
val table = Table()
|
||||
|
||||
//region Label
|
||||
val labelStyle = Label.LabelStyle(
|
||||
BitmapFont(),
|
||||
Color.BLACK
|
||||
)
|
||||
val label = Label("My Label", labelStyle)
|
||||
//endregion
|
||||
|
||||
//region TextButton
|
||||
val textButtonStyle = TextButton.TextButtonStyle(
|
||||
TextureRegionDrawable(Texture("logo.png")),
|
||||
TextureRegionDrawable(Texture("logo.png")),
|
||||
TextureRegionDrawable(Texture("logo.png")),
|
||||
BitmapFont()
|
||||
)
|
||||
val textButton = TextButton("My Text Button", textButtonStyle)
|
||||
//endregion
|
||||
|
||||
override fun show() {
|
||||
stage.addActor(table)
|
||||
|
||||
table.setFillParent(true)
|
||||
table.debug = true
|
||||
|
||||
label.setFontScale(5f)
|
||||
table.add(label)
|
||||
|
||||
table.row()
|
||||
textButton.label.fontScaleX = 10f
|
||||
table.add(textButton)
|
||||
}
|
||||
|
||||
override fun render(delta: Float) {
|
||||
clearScreen(red = 0.7f, green = 0.7f, blue = 0.7f)
|
||||
|
||||
stage.act()
|
||||
stage.draw()
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
stage.dispose()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user