implement support for loading tile animations alongside the rest of a TextureAtlas definition
This commit is contained in:
parent
bfd2748797
commit
6c6ceeeb09
|
@ -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;
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue