SpriteSheetAnimation extends Animation { @Override public void update() { if (!animationStopped) { timeDifference += System.currentTimeMillis() - lastSystemMilliseconds; lastSystemMilliseconds = System.currentTimeMillis(); while (spriteSheet.getDuration() <= timeDifference * speed) { timeDifference -= spriteSheet.getDuration() / speed; frame++; if (frame == getAnimationLength()) { frame = 0; if (!looping) { reset(); } } } } } SpriteSheetAnimation(SpriteSheet spriteSheet);  SpriteSheetAnimation(SpriteSheet spriteSheet, int startingIndex,
                                int length);  SpriteSheetAnimation(SpriteSheet spriteSheet, boolean looping,
                                float speed);  SpriteSheetAnimation(SpriteSheet spriteSheet, boolean looping,
                                float speed, int startingIndex, int length); int getFrameIndex(); @Override void renderAnimation(GraphicsContext graphicsContext, double x,
                                double y); @Override void update(); Point getCurrentImagePoint(); SpriteSheet getSpriteSheet(); void setSpriteSheet(SpriteSheet spriteSheet);  }
@Test public void testUpdate() throws InterruptedException { animation = new SpriteSheetAnimation(spriteSheet); animation.start(); assertTrue(animation.getFrameIndex() == 0); Thread.sleep(100); animation.update(); assertTrue(animation.getFrameIndex() == 1); Thread.sleep(100); animation.update(); assertTrue(animation.getFrameIndex() == 2); }