summaryrefslogtreecommitdiff
path: root/core/src/kz/ilotterytea/maxon/ui
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-06-09 23:25:37 +0500
committerilotterytea <iltsu@alright.party>2024-06-09 23:25:37 +0500
commit8833419a56c090fc357ee483556428196d26ed67 (patch)
treeed7b412b8e10262fd203d3321770a448f909f602 /core/src/kz/ilotterytea/maxon/ui
parentabb6614122bf9eaee9b3b1aa3ac3083c74c40e48 (diff)
feat: fps for animated images
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);
}