@Test public void testGetAnimation_ShouldUpdateDirectionDynamically() { Animation<TextureRegion> animation = cache.getAnimation(ANIMATION_TYPE_A); TextureRegion[] regionsHorizontal = sheet.getFrames(0, 0, 5, 0); TextureRegion[] regionsVertical = sheet.getFrames(0, 0, 0, 5); TextureRegion region_0_0 = regionsHorizontal[0]; TextureRegion region_1_0 = regionsHorizontal[1]; TextureRegion region_0_1 = regionsVertical[1]; assertThat(animation.getKeyFrame(DURATION_A * 0)).isEqualTo(region_0_0); assertThat(animation.getKeyFrame(DURATION_A * 1)).isEqualTo(region_1_0); framesA.setDirection(AnimationFrames.Direction.VERTICAL); animation = cache.getAnimation(ANIMATION_TYPE_A); assertThat(animation.getKeyFrame(DURATION_A * 0)).isEqualTo(region_0_0); assertThat(animation.getKeyFrame(DURATION_A * 1)).isEqualTo(region_0_1); }
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);  }