@Test public void testComputeCurrentFrame() throws Exception { Animation theAnimation = new Animation("Test"); assertNull(theAnimation.computeCurrentFrame(0, 0)); theAnimation = theAnimation.addToAnimationSequence(new ResourceName("1")); theAnimation = theAnimation.addToAnimationSequence(new ResourceName("2")); theAnimation = theAnimation.addToAnimationSequence(new ResourceName("3")); theAnimation = theAnimation.addToAnimationSequence(new ResourceName("4")); theAnimation = theAnimation.addToAnimationSequence(new ResourceName("5")); assertEquals(new ResourceName("1"), theAnimation.computeCurrentFrame(0, 5)); assertEquals(new ResourceName("2"), theAnimation.computeCurrentFrame(200, 5)); assertEquals(new ResourceName("2"), theAnimation.computeCurrentFrame(399, 5)); assertEquals(new ResourceName("3"), theAnimation.computeCurrentFrame(400, 5)); assertEquals(new ResourceName("3"), theAnimation.computeCurrentFrame(599, 5)); assertEquals(new ResourceName("4"), theAnimation.computeCurrentFrame(600, 5)); assertEquals(new ResourceName("4"), theAnimation.computeCurrentFrame(601, 5)); assertEquals(new ResourceName("5"), theAnimation.computeCurrentFrame(800, 5)); assertEquals(new ResourceName("1"), theAnimation.computeCurrentFrame(1000, 5)); assertEquals(new ResourceName("2"), theAnimation.computeCurrentFrame(1200, 5)); assertEquals(new ResourceName("3"), theAnimation.computeCurrentFrame(1400, 5)); assertEquals(new ResourceName("4"), theAnimation.computeCurrentFrame(1600, 5)); assertEquals(new ResourceName("5"), theAnimation.computeCurrentFrame(1800, 5)); }
public ResourceName computeCurrentFrame(long aGameTime, Integer aSpeed) { if (animationSequence.length == 0) { return null; } int theFrame = (int)((aGameTime / 1000d * aSpeed) % animationSequence.length); return animationSequence[theFrame]; }
Animation implements Distributable { public ResourceName computeCurrentFrame(long aGameTime, Integer aSpeed) { if (animationSequence.length == 0) { return null; } int theFrame = (int)((aGameTime / 1000d * aSpeed) % animationSequence.length); return animationSequence[theFrame]; } }
Animation implements Distributable { public ResourceName computeCurrentFrame(long aGameTime, Integer aSpeed) { if (animationSequence.length == 0) { return null; } int theFrame = (int)((aGameTime / 1000d * aSpeed) % animationSequence.length); return animationSequence[theFrame]; } Animation(String aName); private  Animation(String aUUID, String aName, ResourceName[] aAnimationSequence); }
Animation implements Distributable { public ResourceName computeCurrentFrame(long aGameTime, Integer aSpeed) { if (animationSequence.length == 0) { return null; } int theFrame = (int)((aGameTime / 1000d * aSpeed) % animationSequence.length); return animationSequence[theFrame]; } Animation(String aName); private  Animation(String aUUID, String aName, ResourceName[] aAnimationSequence); String getName(); String getUuid(); Animation changeName(String aName); Animation addToAnimationSequence(ResourceName aName); Animation removeFromAnimationSequence(ResourceName aName); Animation removeFromAnimationSequence(int aIndex); int getSequenceSize(); ResourceName getResourceByIndex(int aIndex); ResourceName computeCurrentFrame(long aGameTime, Integer aSpeed); @Override Map<String, Object> serialize(); static Animation deserialize(Map<String, Object> aData); }
Animation implements Distributable { public ResourceName computeCurrentFrame(long aGameTime, Integer aSpeed) { if (animationSequence.length == 0) { return null; } int theFrame = (int)((aGameTime / 1000d * aSpeed) % animationSequence.length); return animationSequence[theFrame]; } Animation(String aName); private  Animation(String aUUID, String aName, ResourceName[] aAnimationSequence); String getName(); String getUuid(); Animation changeName(String aName); Animation addToAnimationSequence(ResourceName aName); Animation removeFromAnimationSequence(ResourceName aName); Animation removeFromAnimationSequence(int aIndex); int getSequenceSize(); ResourceName getResourceByIndex(int aIndex); ResourceName computeCurrentFrame(long aGameTime, Integer aSpeed); @Override Map<String, Object> serialize(); static Animation deserialize(Map<String, Object> aData);  }