implement support for loading tile animations alongside the rest of a TextureAtlas definition

This commit is contained in:
Gered 2013-10-05 19:00:27 -04:00
parent bfd2748797
commit 6c6ceeeb09
3 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,10 @@
package com.blarg.gdx.graphics.atlas;
public class JsonTextureAtlasAnimation {
public String name;
public int tileIndex;
public int startIndex;
public int endIndex;
public float delay;
public boolean loop;
}

View file

@ -5,4 +5,5 @@ import java.util.ArrayList;
public class JsonTextureAtlasDefinition { public class JsonTextureAtlasDefinition {
public String texture; public String texture;
public ArrayList<JsonTextureAtlasTile> tiles; public ArrayList<JsonTextureAtlasTile> tiles;
public ArrayList<JsonTextureAtlasAnimation> animations;
} }

View file

@ -43,6 +43,20 @@ public final class TextureAtlasLoader {
atlas.add(tile.x, tile.y, tile.width, tile.height); atlas.add(tile.x, tile.y, tile.width, tile.height);
} }
if (config.animations != null && config.animations.size() > 0 && animator != null) {
for (int i = 0; i < config.animations.size(); ++i) {
JsonTextureAtlasAnimation animation = config.animations.get(i);
// TODO: parameter value error checking
animator.addSequence(animation.name,
atlas,
animation.tileIndex,
animation.startIndex,
animation.endIndex,
animation.delay,
animation.loop);
}
}
return atlas; return atlas;
} }
} }