Skip to content

Commit

Permalink
Actually cache the animation
Browse files Browse the repository at this point in the history
  • Loading branch information
steffen-wilke committed Dec 14, 2021
1 parent bfc8d2f commit 01da7e0
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public class AnimationController implements IAnimationController {
private final List<ImageEffect> imageEffects;
private final List<AnimationListener> listeners;

/** Initializes a new instance of the {@code AnimationController} class. */
/**
* Initializes a new instance of the {@code AnimationController} class.
*/
public AnimationController() {
this.animations = new ConcurrentHashMap<>();
this.imageEffects = new CopyOnWriteArrayList<>();
Expand Down Expand Up @@ -201,10 +203,15 @@ public BufferedImage getCurrentImage() {

BufferedImage sprite =
current.getSpritesheet().getSprite(current.getCurrentKeyFrame().getSpriteIndex());
if (sprite == null) {
return null;
}
for (final ImageEffect effect : this.getImageEffects()) {
sprite = effect.apply(sprite);
}

Resources.images().add(cacheKey, sprite);

return sprite;
}

Expand Down

0 comments on commit 01da7e0

Please sign in to comment.