From ad15f2850c44463a30a34c1924cd3ca5485840b1 Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 14 Apr 2014 14:19:45 -0400 Subject: [PATCH] add method to register/copy all animations from a TextureAtlas at once --- .../gdx/graphics/atlas/TextureAtlasAnimator.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/ca/blarg/gdx/graphics/atlas/TextureAtlasAnimator.java b/src/main/java/ca/blarg/gdx/graphics/atlas/TextureAtlasAnimator.java index 693670f..1716f40 100644 --- a/src/main/java/ca/blarg/gdx/graphics/atlas/TextureAtlasAnimator.java +++ b/src/main/java/ca/blarg/gdx/graphics/atlas/TextureAtlasAnimator.java @@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.TextureData; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.ObjectMap; -import ca.blarg.gdx.graphics.GraphicsHelpers; /** * Animation manager class for animation sequences made up of tiles in a {@link TextureAtlas}. This class should only @@ -25,6 +24,16 @@ public class TextureAtlasAnimator implements Disposable { animations = new ObjectMap(); } + public void add(TextureAtlas atlas) { + if (atlas == null) + throw new IllegalArgumentException("atlas cannot be null."); + + for (ObjectMap.Entry i : atlas.getAnimations()) { + TextureAtlas.Animation animation = i.value; + addSequence(i.key, atlas, animation.destTileIndex, animation.start, animation.stop, animation.delay, animation.loop); + } + } + public void addSequence(String name, TextureAtlas atlas, int tileToBeAnimated, int start, int stop, float delay, boolean loop) { if (animations.containsKey(name)) throw new UnsupportedOperationException("Duplicate animation sequence name.");