TextureAtlasDesc can really just be a static class like it was before..
This commit is contained in:
parent
8e1d8bf3d0
commit
49885cb5d8
|
@ -8,17 +8,17 @@ import com.badlogic.gdx.files.FileHandle;
|
|||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
|
||||
public class TextureAtlasDesc {
|
||||
public JsonTextureAtlasDefinition load(FileHandle file) {
|
||||
public class TextureAtlasJsonLoader {
|
||||
public static JsonTextureAtlasDefinition load(FileHandle file) {
|
||||
Json json = new Json();
|
||||
return json.fromJson(JsonTextureAtlasDefinition.class, file);
|
||||
}
|
||||
|
||||
public TextureAtlas create(JsonTextureAtlasDefinition definition) {
|
||||
public static TextureAtlas create(JsonTextureAtlasDefinition definition) {
|
||||
return create(definition, null);
|
||||
}
|
||||
|
||||
public TextureAtlas create(JsonTextureAtlasDefinition definition, AssetManager assetManager) {
|
||||
public static TextureAtlas create(JsonTextureAtlasDefinition definition, AssetManager assetManager) {
|
||||
if (definition.texture == null)
|
||||
throw new RuntimeException("No texture specified.");
|
||||
if (definition.tiles == null || definition.tiles.size() == 0)
|
|
@ -15,16 +15,14 @@ import com.badlogic.gdx.utils.Array;
|
|||
public class TextureAtlasLoader extends AsynchronousAssetLoader<TextureAtlas, TextureAtlasLoader.TextureAtlasParameter> {
|
||||
public TextureAtlasLoader(FileHandleResolver resolver) {
|
||||
super(resolver);
|
||||
desc = new TextureAtlasDesc();
|
||||
}
|
||||
|
||||
final TextureAtlasDesc desc;
|
||||
JsonTextureAtlasDefinition definition;
|
||||
TextureAtlas atlas;
|
||||
|
||||
@Override
|
||||
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureAtlasParameter parameter) {
|
||||
definition = desc.load(file);
|
||||
definition = TextureAtlasJsonLoader.load(file);
|
||||
Array<AssetDescriptor> deps = new Array<AssetDescriptor>();
|
||||
deps.add(new AssetDescriptor(definition.texture, Texture.class));
|
||||
return deps;
|
||||
|
@ -32,7 +30,7 @@ public class TextureAtlasLoader extends AsynchronousAssetLoader<TextureAtlas, Te
|
|||
|
||||
@Override
|
||||
public void loadAsync(AssetManager manager, String fileName, FileHandle file, TextureAtlasParameter parameter) {
|
||||
atlas = desc.create(definition, manager);
|
||||
atlas = TextureAtlasJsonLoader.create(definition, manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue