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.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java b/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java
index 19ec0dc..e6278c5 100644
--- a/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java
+++ b/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java
@@ -8,17 +8,25 @@ import com.badlogic.gdx.utils.Disposable;
public class AnimatedImage extends Image implements Disposable {
private final TextureRegion[] regions;
- private int index = 0;
+ private final int fps;
+ private int index = 0, seconds = 0;
private boolean stopAnim = false;
public AnimatedImage(TextureRegion[] regions) {
super(regions[0]);
this.regions = regions;
+ this.fps = 0;
+ }
+
+ public AnimatedImage(TextureRegion[] regions, int fps) {
+ super(regions[0]);
+ this.regions = regions;
+ this.fps = fps;
}
@Override public void act(float delta) {
- if (!stopAnim) {
+ if (!stopAnim && seconds >= fps) {
if (index > regions.length - 1) {
index = 0;
}
@@ -30,7 +38,10 @@ public class AnimatedImage extends Image implements Disposable {
super.setDrawable(new TextureRegionDrawable(regions[index]));
index++;
+ seconds = 0;
}
+
+ seconds++;
super.act(delta);
}