Java 类com.badlogic.gdx.assets.loaders.TextureAtlasLoader 实例源码

项目:libgdxcn    文件:AssetManager.java   
/** Creates a new AssetManager with all default loaders. */
public AssetManager (FileHandleResolver resolver) {
    setLoader(BitmapFont.class, new BitmapFontLoader(resolver));
    setLoader(Music.class, new MusicLoader(resolver));
    setLoader(Pixmap.class, new PixmapLoader(resolver));
    setLoader(Sound.class, new SoundLoader(resolver));
    setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));
    setLoader(Texture.class, new TextureLoader(resolver));
    setLoader(Skin.class, new SkinLoader(resolver));
    setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver));
    setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver));
    setLoader(I18NBundle.class, new I18NBundleLoader(resolver));
    setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver));
    setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver));
    setLoader(Model.class, ".obj", new ObjLoader(resolver));
    executor = new AsyncExecutor(1);
}
项目:cocos-ui-libgdx    文件:CCTextureAtlasLoader.java   
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureAtlasLoader.TextureAtlasParameter parameter) {
    FileHandle imgDir = file.parent();
    map = LyU.createDictionaryWithContentsOfFile(file);
    ObjectMap<String, Object> metadata = (ObjectMap<String, Object>) map.get("metadata");
    String dependFile = (String) metadata.get("textureFileName");
    Array<AssetDescriptor> res = new Array<AssetDescriptor>();
    TextureLoader.TextureParameter params = new TextureLoader.TextureParameter();
    params.magFilter = Texture.TextureFilter.Linear;
    params.minFilter = Texture.TextureFilter.Linear;
    params.format = Pixmap.Format.RGBA8888;
    texture = new Texture(imgDir.child(dependFile));
    res.add(new AssetDescriptor(imgDir.child(dependFile), Texture.class, params));
    return res;
}
项目:bladecoder-adventure-engine    文件:EngineAssetManager.java   
protected EngineAssetManager(FileHandleResolver resolver) {
    super(resolver);

    resResolver = new EngineResolutionFileResolver(resolver);
    setLoader(Texture.class, new TextureLoader(resResolver));
    setLoader(TextureAtlas.class, new TextureAtlasLoader(resResolver));
    setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));

    Texture.setAssetManager(this);
}
项目:cocos-ui-libgdx    文件:CCTextureAtlasLoader.java   
@Override
public TextureAtlas load(AssetManager assetManager, String fileName, FileHandle file, TextureAtlasLoader.TextureAtlasParameter parameter) {
    TextureAtlas atlas = new TextureAtlas();
    atlas.getTextures().add(texture);
    ObjectMap<String, Object> frames = (ObjectMap<String, Object>) map.get("frames");
    for (ObjectMap.Entry<String, Object> entry : frames.entries()) {
        String pageName = entry.key;
        ObjectMap<String, Object> params = (ObjectMap<String, Object>) entry.value;
        Rectangle frame = LyU.parseRect((String) params.get("frame"));
        GridPoint2 offset = LyU.parsePoint((String) params.get("offset"));
        boolean rotated = Boolean.parseBoolean((String) params.get("rotated"));
        GridPoint2 sourceSize = LyU.parsePoint((String) params.get("sourceSize"));
        Rectangle sourceColorRect = LyU.parseRect((String) params.get("sourceColorRect"));
        TextureAtlas.TextureAtlasData.Region region = new TextureAtlas.TextureAtlasData.Region();
        region.name = pageName.substring(0, pageName.lastIndexOf('.'));
        region.rotate = rotated;
        region.offsetX = offset.x;
        region.offsetY = offset.y;
        region.originalWidth = sourceSize.x;
        region.originalHeight = sourceSize.y;
        region.left = (int) frame.x;
        region.top = (int) frame.y;
        region.width = (int) frame.getWidth();
        region.height = (int) frame.getHeight();
        int width = region.width;
        int height = region.height;
        TextureAtlas.AtlasRegion atlasRegion = new TextureAtlas.AtlasRegion(texture, region.left, region.top,
            region.rotate ? height : width, region.rotate ? width : height);
        atlasRegion.index = region.index;
        atlasRegion.name = region.name;
        atlasRegion.offsetX = region.offsetX;
        atlasRegion.offsetY = region.offsetY;
        atlasRegion.originalHeight = region.originalHeight;
        atlasRegion.originalWidth = region.originalWidth;
        atlasRegion.rotate = region.rotate;
        atlasRegion.splits = region.splits;
        atlasRegion.pads = region.pads;
        if (region.flip) {
            atlasRegion.flip(false, true);
        }
        atlas.getRegions().add(atlasRegion);
    }
    texture = null;
    map = null;
    return atlas;
}