Back to project page Flumpgdx.
The source code is released under:
Copyright (c) 2014 Daniyal Khan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softw...
If you think the Android project Flumpgdx listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.flumpgdx.library; /*from w ww .ja va2 s . c om*/ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.utils.Json; import com.badlogic.gdx.utils.JsonWriter.OutputType; import com.badlogic.gdx.utils.ObjectMap; import com.flumpgdx.display.FlumpDisplayTexture; import com.flumpgdx.display.TextureCache; public class FlumpLibraryFile { private static final String JSON_FILE = "library.json"; String jsonDir; int frameRate; String md5; FlumpTextureGroup[] textureGroups; FlumpMovie[] movies; ObjectMap<String, FlumpMovie> animations; public static FlumpLibraryFile deserialize(String jsonDir) { if (!jsonDir.endsWith("/")) jsonDir += "/"; FlumpLibraryFile f = new Json(OutputType.json).fromJson(FlumpLibraryFile.class, Gdx.files.internal(jsonDir + JSON_FILE)); f.jsonDir = jsonDir; return f.init(); } public String getDir() { return jsonDir; } private FlumpLibraryFile init() { //list of all animations in this file animations = new ObjectMap<String, FlumpMovie>(); //create a new TextureRegion for each FlumpRegion in the file for (FlumpTextureGroup group: textureGroups) { for (FlumpAtlas atlas: group.atlases) { Texture texture = new Texture(Gdx.files.internal(jsonDir + atlas.file)); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); for (FlumpTextureRegion region: atlas.textures) { TextureCache.obtain().cache(region.symbol, new FlumpDisplayTexture(texture, region)); region.rect = null; //avoid loitering } atlas.textures = null; //avoid loitering } group.atlases = null; //avoid loitering } textureGroups = null; //avoid loitering //create a new animation for each animation in the file for (FlumpMovie movie: movies) animations.put(movie.id, movie); return this; } }