summaryrefslogtreecommitdiff
path: root/core/src/kz/ilotterytea/maxon/ui
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/ui')
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java b/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java
index e6278c5..d1f5b90 100644
--- a/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java
+++ b/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java
@@ -6,37 +6,39 @@ import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Disposable;
+import java.util.ArrayList;
+
public class AnimatedImage extends Image implements Disposable {
- private final TextureRegion[] regions;
+ private final ArrayList<TextureRegion> regions;
private final int fps;
private int index = 0, seconds = 0;
private boolean stopAnim = false;
- public AnimatedImage(TextureRegion[] regions) {
- super(regions[0]);
+ public AnimatedImage(ArrayList<TextureRegion> regions) {
+ super(regions.get(0));
this.regions = regions;
this.fps = 0;
}
- public AnimatedImage(TextureRegion[] regions, int fps) {
- super(regions[0]);
+ public AnimatedImage(ArrayList<TextureRegion> regions, int fps) {
+ super(regions.get(0));
this.regions = regions;
this.fps = fps;
}
@Override public void act(float delta) {
if (!stopAnim && seconds >= fps) {
- if (index > regions.length - 1) {
+ if (index > regions.size() - 1) {
index = 0;
}
try {
- if (regions[index + 1] == null) {
+ if (regions.get(index + 1) == null) {
index = 0;
}
- } catch (ArrayIndexOutOfBoundsException ignored) {}
+ } catch (IndexOutOfBoundsException ignored) {}
- super.setDrawable(new TextureRegionDrawable(regions[index]));
+ super.setDrawable(new TextureRegionDrawable(regions.get(index)));
index++;
seconds = 0;
}
@@ -45,18 +47,18 @@ public class AnimatedImage extends Image implements Disposable {
super.act(delta);
}
- public TextureRegion getFrame(int index) { return regions[index]; }
+ public TextureRegion getFrame(int index) { return regions.get(index); }
public int getIndex() { return index; }
public Drawable getDrawable() { return super.getDrawable(); }
public void nextFrame() {
index++;
- if (index > regions.length - 1 || regions[index] == null) {
+ if (index > regions.size() - 1 || regions.get(index) == null) {
index = 0;
}
- super.setDrawable(new TextureRegionDrawable(regions[index]));
+ super.setDrawable(new TextureRegionDrawable(regions.get(index)));
}
public void disableAnim() { stopAnim = true; }