summaryrefslogtreecommitdiff
path: root/core/src/kz/ilotterytea/maxon/ui
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-10-06 00:52:49 +0500
committerilotterytea <iltsu@alright.party>2024-10-06 00:52:49 +0500
commit3de9d004e99851f38f8700839fa2f7aa6f1c0172 (patch)
treebe1138744ea911e5b2fb56461f2bd998298b1d3e /core/src/kz/ilotterytea/maxon/ui
parent964aca366e36b8d3a60d57bbbb2838cd04314e03 (diff)
feat: shaking image (button)
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/ui')
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt37
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt3
2 files changed, 39 insertions, 1 deletions
diff --git a/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt b/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt
new file mode 100644
index 0000000..eb8c51c
--- /dev/null
+++ b/core/src/kz/ilotterytea/maxon/ui/ShakingImageButton.kt
@@ -0,0 +1,37 @@
+package kz.ilotterytea.maxon.ui
+
+import com.badlogic.gdx.scenes.scene2d.Actor
+import com.badlogic.gdx.scenes.scene2d.InputEvent
+import com.badlogic.gdx.scenes.scene2d.actions.Actions
+import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction
+import com.badlogic.gdx.scenes.scene2d.ui.Image
+import com.badlogic.gdx.scenes.scene2d.ui.Skin
+import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
+
+class ShakingImageButton(skin: Skin, style: String) : Image(skin.getRegion(style)) {
+ init {
+ setOrigin(width / 2f, height / 2f)
+
+ addListener(object : ClickListener() {
+ override fun enter(event: InputEvent?, x: Float, y: Float, pointer: Int, fromActor: Actor?) {
+ super.enter(event, x, y, pointer, fromActor)
+
+ addAction(
+ Actions.repeat(
+ RepeatAction.FOREVER,
+ Actions.sequence(
+ Actions.rotateTo(-2f, 0.1f),
+ Actions.rotateTo(2f, 0.1f)
+ )
+ )
+ )
+ }
+
+ override fun exit(event: InputEvent?, x: Float, y: Float, pointer: Int, toActor: Actor?) {
+ super.exit(event, x, y, pointer, toActor)
+ clearActions()
+ addAction(Actions.rotateTo(0f, 0.1f))
+ }
+ })
+ }
+} \ No newline at end of file
diff --git a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt
index b5df026..c2c1667 100644
--- a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt
+++ b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt
@@ -12,11 +12,12 @@ import com.badlogic.gdx.utils.Align
import kz.ilotterytea.maxon.MaxonGame
import kz.ilotterytea.maxon.player.Savegame
import kz.ilotterytea.maxon.screens.MenuScreen
+import kz.ilotterytea.maxon.ui.ShakingImageButton
class QuickActionsTable(skin: Skin) : Table() {
init {
val game = MaxonGame.getInstance()
- val quitButton = ImageButton(skin, "quit")
+ val quitButton = ShakingImageButton(skin, "exit")
val clickSound = game.assetManager.get("sfx/ui/click.ogg", Sound::class.java)