Skip to content

Commit

Permalink
Animation.java: Separate frame update from frame getters thus impleme…
Browse files Browse the repository at this point in the history
…nting its update method
  • Loading branch information
rust2 committed Nov 2, 2024
1 parent 457c03a commit 046346f
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions core/src/fluddokt/opsu/fake/Animation.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,29 @@ public void addFrame(Image img, int dura) {

@Override
public TextureRegion getTextureRegion() {
while (System.currentTimeMillis() - lastUpdate > imgs.get(curFrame).duration) {
lastUpdate = System.currentTimeMillis();
curFrame = (curFrame + 1) % getFrameCount();
}
// while (System.currentTimeMillis() - lastUpdate > imgs.get(curFrame).duration) {
// lastUpdate = System.currentTimeMillis();
// curFrame = (curFrame + 1) % getFrameCount();
// }
// System.out.println("curFrame Anim:"+curFrame);
return getImage(curFrame).tex;
}

public Image getCurrentFrame() {
while (System.currentTimeMillis() - lastUpdate > imgs.get(curFrame).duration) {
lastUpdate = System.currentTimeMillis();
curFrame = (curFrame + 1) % getFrameCount();
}
// while (System.currentTimeMillis() - lastUpdate > imgs.get(curFrame).duration) {
// lastUpdate = System.currentTimeMillis();
// curFrame = (curFrame + 1) % getFrameCount();
// }
return getImage(curFrame);
}

@Deprecated
public void updateNoDraw() {
// TODO Auto-generated method stub

// separated from getters: getTextureRegion and getCurrentFrame
while (System.currentTimeMillis() - lastUpdate > imgs.get(curFrame).duration) {
lastUpdate = System.currentTimeMillis();
curFrame = (curFrame + 1) % getFrameCount();
}
}

}

0 comments on commit 046346f

Please sign in to comment.