Experiment with creating buttons for a main menu
This commit is contained in:
@@ -12,7 +12,7 @@ class AndroidLauncher : AndroidApplication() {
|
||||
super.onCreate(savedInstanceState)
|
||||
initialize(Main(), AndroidApplicationConfiguration().apply {
|
||||
// Configure your application here.
|
||||
useImmersiveMode = true // Recommended, but not required.
|
||||
//useImmersiveMode = true // Recommended, but not required.
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ dependencies {
|
||||
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
||||
api "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
api "com.github.kotcrab.vis-ui:vis-ui:$visUiVersion"
|
||||
api "io.github.libktx:ktx-actors:$ktxVersion"
|
||||
api "io.github.libktx:ktx-ai:$ktxVersion"
|
||||
api "io.github.libktx:ktx-app:$ktxVersion"
|
||||
|
||||
@@ -15,8 +15,10 @@ class Main : KtxGame<KtxScreen>() {
|
||||
override fun create() {
|
||||
KtxAsync.initiate()
|
||||
|
||||
addScreen(FirstScreen())
|
||||
setScreen<FirstScreen>()
|
||||
// addScreen(FirstScreen())
|
||||
// setScreen<FirstScreen>()
|
||||
addScreen(MainMenu())
|
||||
setScreen<MainMenu>()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.iofferyoutea.WitchQueen
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage
|
||||
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.KtxScreen
|
||||
import ktx.app.clearScreen
|
||||
import ktx.assets.toInternalFile
|
||||
import com.badlogic.gdx.graphics.Texture.TextureFilter.Nearest
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin
|
||||
|
||||
class MainMenu : KtxScreen {
|
||||
val table = Table().apply {
|
||||
setFillParent(true)
|
||||
debug = true
|
||||
}
|
||||
val stage = Stage().apply {
|
||||
Gdx.input.inputProcessor = this
|
||||
addActor(table)
|
||||
}
|
||||
|
||||
val mySkin = Skin("uiskin.json".toInternalFile())
|
||||
|
||||
val textureRegion = TextureRegion(Texture("default.png").apply { setFilter(Nearest,
|
||||
Nearest
|
||||
)} )
|
||||
val buttonFont = BitmapFont("default.fnt".toInternalFile())
|
||||
val style = TextButton.TextButtonStyle().apply { up = TextureRegionDrawable(textureRegion); font = buttonFont }
|
||||
|
||||
val button = TextButton("Button", style).apply {
|
||||
table.add(this).size(512f, 512f)
|
||||
}
|
||||
|
||||
override fun render(delta: Float) {
|
||||
super.render(delta)
|
||||
clearScreen(0f, 255f, 0f)
|
||||
|
||||
stage.act(delta)
|
||||
stage.draw()
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
stage.dispose()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user