summaryrefslogtreecommitdiff
path: root/core/src/com/ilotterytea/maxoning/ui
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2022-08-29 00:40:49 +0600
committerilotterytea <iltsu@alright.party>2022-08-29 00:40:49 +0600
commit42f5238c3341437e9d55f14715033b03aad60fc8 (patch)
treeca0b1c69688f0042fb4c6c4da0f1ab57aac462a1 /core/src/com/ilotterytea/maxoning/ui
parent5ce75c990a9f7b77a5c52afb565b3ba92a07593a (diff)
важное переименовывание папок
Diffstat (limited to 'core/src/com/ilotterytea/maxoning/ui')
-rw-r--r--core/src/com/ilotterytea/maxoning/ui/AnimatedImage.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/core/src/com/ilotterytea/maxoning/ui/AnimatedImage.java b/core/src/com/ilotterytea/maxoning/ui/AnimatedImage.java
new file mode 100644
index 0000000..521059e
--- /dev/null
+++ b/core/src/com/ilotterytea/maxoning/ui/AnimatedImage.java
@@ -0,0 +1,38 @@
+package com.ilotterytea.maxoning.ui;
+
+import com.badlogic.gdx.graphics.g2d.Animation;
+import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import com.badlogic.gdx.scenes.scene2d.ui.Image;
+import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
+
+public class AnimatedImage extends Image {
+ private float stateTime = 0;
+ private final TextureRegion[] regions;
+ private int index = 0;
+
+ public AnimatedImage(TextureRegion[] regions) {
+ super(regions[0]);
+ this.regions = regions;
+ }
+
+ @Override public void act(float delta) {
+ if (index > regions.length - 1) {
+ index = 0;
+ }
+ if (regions[index + 1] == null) {
+ index = 0;
+ }
+ super.setDrawable(new TextureRegionDrawable(regions[index]));
+ index++;
+ super.act(delta);
+
+ }
+
+ public void dispose() {
+ for (TextureRegion reg : regions) {
+ if (reg != null) {
+ reg.getTexture().dispose();
+ }
+ }
+ }
+}