add TextureAtlas asset loading support for a MaterialTileMapping reference

This commit is contained in:
Gered 2014-04-15 16:56:37 -04:00
parent de6f7ecc77
commit 7aa79d4652
2 changed files with 10 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package ca.blarg.gdx.assets.textureatlas;
import ca.blarg.gdx.assets.AssetLoadingException;
import ca.blarg.gdx.graphics.atlas.CustomGridTextureAtlas;
import ca.blarg.gdx.graphics.atlas.MaterialTileMapping;
import ca.blarg.gdx.graphics.atlas.TextureAtlas;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.files.FileHandle;
@ -21,8 +22,11 @@ class TextureAtlasJsonLoader {
throw new AssetLoadingException(file.path(), "No tiles defined.");
Texture texture = assetManager.get(definition.texture, Texture.class);
MaterialTileMapping materialTileMapping = null;
if (definition.materialMapping != null)
materialTileMapping = assetManager.get(definition.materialMapping, MaterialTileMapping.class);
CustomGridTextureAtlas atlas = new CustomGridTextureAtlas(texture);
CustomGridTextureAtlas atlas = new CustomGridTextureAtlas(texture, materialTileMapping);
for (int i = 0; i < definition.tiles.size(); ++i) {
JsonTextureAtlasTile tile = definition.tiles.get(i);
// TODO: parameter value error checking

View file

@ -1,5 +1,6 @@
package ca.blarg.gdx.assets.textureatlas;
import ca.blarg.gdx.graphics.atlas.MaterialTileMapping;
import ca.blarg.gdx.graphics.atlas.TextureAtlas;
import com.badlogic.gdx.assets.AssetDescriptor;
import com.badlogic.gdx.assets.AssetLoaderParameters;
@ -23,7 +24,11 @@ public class TextureAtlasLoader extends AsynchronousAssetLoader<TextureAtlas, Te
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureAtlasParameter parameter) {
definition = TextureAtlasJsonLoader.load(file);
Array<AssetDescriptor> deps = new Array<AssetDescriptor>();
deps.add(new AssetDescriptor(definition.texture, Texture.class));
if (definition.materialMapping != null)
deps.add(new AssetDescriptor(definition.materialMapping, MaterialTileMapping.class));
return deps;
}