@Test public void testGetAnimation_ShouldSupportIndividualPlayModes_IncludingCaching() { Animation<TextureRegion> animationA = cache.getAnimation(ANIMATION_TYPE_A); Animation<TextureRegion> animationB = cache.getAnimation(ANIMATION_TYPE_B); boolean reversed = false; for (float time = 0f; time < 10f; time += 1f) { TextureRegion regionA = animationA.getKeyFrame(time); TextureRegion regionB = animationB.getKeyFrame(time * 2); if (time != 0 && time % FRAME_COUNT == 0) { reversed = true; } if (reversed) { assertThat(regionA).isNotEqualTo(regionB); } else { assertThat(regionA).isEqualTo(regionB); } } }
public Animation<TextureRegion> getAnimation(Object animationType) { Animation<TextureRegion> animation = animations.get(animationType); if (animation == null || hasDirectionChanged(animationType)) { TextureRegion[] regions = getRegionsForType(animationType); AnimationFrames frames = config.getFrames(animationType); animation = new Animation<TextureRegion>(frames.getDuration(), regions); animations.put(animationType, animation); directionMap.put(animationType, frames.getDirection()); } updateAnimation(animationType, animation); return animation; }
AnimationCache { public Animation<TextureRegion> getAnimation(Object animationType) { Animation<TextureRegion> animation = animations.get(animationType); if (animation == null || hasDirectionChanged(animationType)) { TextureRegion[] regions = getRegionsForType(animationType); AnimationFrames frames = config.getFrames(animationType); animation = new Animation<TextureRegion>(frames.getDuration(), regions); animations.put(animationType, animation); directionMap.put(animationType, frames.getDirection()); } updateAnimation(animationType, animation); return animation; } }
AnimationCache { public Animation<TextureRegion> getAnimation(Object animationType) { Animation<TextureRegion> animation = animations.get(animationType); if (animation == null || hasDirectionChanged(animationType)) { TextureRegion[] regions = getRegionsForType(animationType); AnimationFrames frames = config.getFrames(animationType); animation = new Animation<TextureRegion>(frames.getDuration(), regions); animations.put(animationType, animation); directionMap.put(animationType, frames.getDirection()); } updateAnimation(animationType, animation); return animation; } AnimationCache(AnimationSpriteSheet spriteSheet, AnimationConfig config); }
AnimationCache { public Animation<TextureRegion> getAnimation(Object animationType) { Animation<TextureRegion> animation = animations.get(animationType); if (animation == null || hasDirectionChanged(animationType)) { TextureRegion[] regions = getRegionsForType(animationType); AnimationFrames frames = config.getFrames(animationType); animation = new Animation<TextureRegion>(frames.getDuration(), regions); animations.put(animationType, animation); directionMap.put(animationType, frames.getDirection()); } updateAnimation(animationType, animation); return animation; } AnimationCache(AnimationSpriteSheet spriteSheet, AnimationConfig config); Animation<TextureRegion> getAnimation(Object animationType); }
AnimationCache { public Animation<TextureRegion> getAnimation(Object animationType) { Animation<TextureRegion> animation = animations.get(animationType); if (animation == null || hasDirectionChanged(animationType)) { TextureRegion[] regions = getRegionsForType(animationType); AnimationFrames frames = config.getFrames(animationType); animation = new Animation<TextureRegion>(frames.getDuration(), regions); animations.put(animationType, animation); directionMap.put(animationType, frames.getDirection()); } updateAnimation(animationType, animation); return animation; } AnimationCache(AnimationSpriteSheet spriteSheet, AnimationConfig config); Animation<TextureRegion> getAnimation(Object animationType);  }