From c34e49dbf0155ad89579d8df45a717aeef8adb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 13 Oct 2018 21:30:33 +0200 Subject: AnimationSequence : small improvements --- .../boardgame/animations/AnimationSequence.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/src/ch/asynk/gdx/boardgame/animations/AnimationSequence.java b/core/src/ch/asynk/gdx/boardgame/animations/AnimationSequence.java index 4732c53..88bb15b 100644 --- a/core/src/ch/asynk/gdx/boardgame/animations/AnimationSequence.java +++ b/core/src/ch/asynk/gdx/boardgame/animations/AnimationSequence.java @@ -47,32 +47,34 @@ public class AnimationSequence implements Animation, Pool.Poolable animationSequencePool.free(this); } - public void addAnimation(Animation animation) + public void add(Animation animation) { animations.add(animation); } @Override public boolean completed() { - return (animations.size() == 0); + return animations.isEmpty(); } @Override public boolean animate(float delta) { - if (animations.isEmpty()) return true; - - Animation animation = animations.get(0); - if (animation.animate(delta)) { - animations.remove(0); - animation.dispose(); + if (!completed()) { + Animation animation = animations.get(0); + if (animation.animate(delta)) { + animations.remove(0); + animation.dispose(); + } } - return (animations.isEmpty()); + return completed(); } @Override public void draw(Batch batch) { - animations.get(0).draw(batch); + if (!completed()) { + animations.get(0).draw(batch); + } } @Override public void drawDebug(ShapeRenderer debugShapes) -- cgit v1.1-2-g2b99