Java 类com.badlogic.gdx.assets.AssetDescriptor 实例源码

项目:KyperBox    文件:KyperMapLoader.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle tmxFile,
        com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) {
    Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
    try {
        root = xml.parse(tmxFile);

        Element properties = root.getChildByName("properties");
        if (properties != null) {
            for (Element property : properties.getChildrenByName("property")) {
                String name = property.getAttribute("name");
                String value = property.getAttribute("value");
                if (name.startsWith("atlas")) {
                    FileHandle atlasHandle = Gdx.files.internal(value);
                    dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class));
                }
            }
        }
    } catch (IOException e) {
        throw new GdxRuntimeException("Unable to parse .tmx file.");
    }
    return dependencies;
}
项目:fabulae    文件:LoaderUtil.java   
public static <T, P extends AssetLoaderParameters<T>> void handleImports(
        AssetLoader<T, P> loader, P parameter,
        @SuppressWarnings("rawtypes") Array<AssetDescriptor> dependencies, FileHandle parentFile,
        Element root) throws IOException {
    Array<Element> imports = root.getChildrenByName(XMLUtil.XML_IMPORT);
    for (Element singleImport : imports) {
        String filename = singleImport.get(XMLUtil.XML_FILENAME);
        FileHandle file = parentFile.parent().child(filename);
        if (!file.exists()) {
            throw new GdxRuntimeException("Import " + file.path()
                    + " from import for " + parentFile.name()
                    + " does not exist.");
        }
        dependencies.addAll(loader.getDependencies(filename, file, parameter));
    }
}
项目:fabulae    文件:ProjectileTypeLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, ProjectileTypeParameter parameter) {
    XmlReader xmlReader = new XmlReader();
    try {
        Array<AssetDescriptor>  returnValue = new Array<AssetDescriptor>();
        Element root = xmlReader.parse(file);
        LoaderUtil.handleImports(this, parameter, returnValue, file, root);
        String animationFile = root.get(ProjectileType.XML_ANIMATION_FILE, null);
        if (animationFile != null) {
            returnValue.add(new AssetDescriptor<Texture>(Configuration.addModulePath(animationFile), Texture.class));
        }
        Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
        if (soundsElement != null) {
            addSoundDependency(soundsElement, ProjectileType.XML_ON_START, returnValue);
            addSoundDependency(soundsElement, ProjectileType.XML_ON_HIT, returnValue);
            addSoundDependency(soundsElement, ProjectileType.XML_DURING, returnValue);
        }
        if (returnValue.size > 0) {
            return returnValue;
        }
    } catch (IOException e) {
        throw new GdxRuntimeException(e);
    }
    return null;
}
项目:fabulae    文件:WeatherProfileLoader.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, WeatherProfileParameter parameter) {
    Array<AssetDescriptor> returnValue = new Array<AssetDescriptor>();
    try {
        XmlReader xmlReader = new XmlReader();
        Element root = xmlReader.parse(file);
        LoaderUtil.handleImports(this, parameter, returnValue, file, root);
        Array<Element> trackElements = root.getChildrenByNameRecursively(WeatherProfile.XML_TRACK);
        for (Element trackElement : trackElements) {
            String trackFileName = Configuration.addModulePath(trackElement.get(XMLUtil.XML_ATTRIBUTE_FILENAME));
            returnValue.add(new AssetDescriptor(trackFileName, WeatherProfile.XML_CONTINOUS.equalsIgnoreCase(trackElement.getParent().getName()) ? Music.class : Sound.class)); 
        }
    } catch (IOException e) {
        throw new GdxRuntimeException(e);
    }

    return returnValue;
}
项目:fabulae    文件:TrapLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, TrapParameter parameter) {
    XmlReader xmlReader = new XmlReader();
    try {
        Array<AssetDescriptor>  returnValue = new Array<AssetDescriptor>();
        Element root = xmlReader.parse(file);
        LoaderUtil.handleImports(this, parameter, returnValue, file, root);
        Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
        if (soundsElement != null) {
            addSoundDependency(soundsElement, TrapType.XML_DISARMED, returnValue);
            addSoundDependency(soundsElement, TrapType.XML_SPRUNG, returnValue);
        }
        if (returnValue.size > 0) {
            return returnValue;
        }
    } catch (IOException e) {
        throw new GdxRuntimeException(e);
    }
    return null;
}
项目:libgdxjam    文件:AnimationControlLoader.java   
@Override
public Array<AssetDescriptor> getDependencies(String fileName,
        FileHandle file, Parameter parameter) {

    JsonValue root = reader.parse(file);
    String spineFile = root.getString("spine");

    Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
    dependencies.add(new AssetDescriptor(
        spineFile,
        SkeletonData.class,
        getSkeletonParameters(spineFile)
    ));

    return dependencies;
}
项目:ProjektGG    文件:LoadingScreen.java   
public final AssetDescriptor<BitmapFont> MAIN_FONT_19_PATH() {
    FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
    font.fontFileName = "fonts/AlemdraSC/AlmendraSC-Regular.ttf";
    font.fontParameters.size = 19;
    return new AssetDescriptor<BitmapFont>("mainFont19.ttf",
            BitmapFont.class, font);
}
项目:ProjektGG    文件:LoadingScreen.java   
public final AssetDescriptor<BitmapFont> MAIN_FONT_22_PATH() {
    FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
    font.fontFileName = "fonts/AlemdraSC/AlmendraSC-Regular.ttf";
    font.fontParameters.size = 22;
    return new AssetDescriptor<BitmapFont>("mainFont22.ttf",
            BitmapFont.class, font);
}
项目:ProjektGG    文件:LoadingScreen.java   
public final AssetDescriptor<BitmapFont> LETTER_FONT_20_PATH() {
    FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
    font.fontFileName = "fonts/Fredericka_the_Great/FrederickatheGreat-Regular.ttf";
    font.fontParameters.size = 20;
    return new AssetDescriptor<BitmapFont>("letterFont20.ttf",
            BitmapFont.class, font);
}
项目:ProjektGG    文件:LoadingScreen.java   
public final AssetDescriptor<BitmapFont> HANDWRITTEN_FONT_20_PATH() {
    FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
    font.fontFileName = "fonts/ReenieBeanie/ReenieBeanie.ttf";
    font.fontParameters.size = 20;
    return new AssetDescriptor<BitmapFont>("handwrittenFont20.ttf",
            BitmapFont.class, font);
}
项目:gdx-cclibs    文件:AssignmentAssetManager.java   
@Override
public synchronized boolean update () {
    boolean done = super.update();
    if (done) {
        // assign references to Asset fields of queuedContainers
        for (Object assetContainer : queuedContainers) {
            ObjectMap<Field, AssetDescriptor<?>> fieldsToAssets = containersFieldsToAssets.get(assetContainer);
            for (ObjectMap.Entry<Field, AssetDescriptor<?>> fieldEntry : fieldsToAssets) {
                Field field = fieldEntry.key;
                makeAccessible(field);
                try {
                    field.set(assetContainer, get(fieldEntry.value));
                } catch (ReflectionException e) {
                    throw new GdxRuntimeException("Failed to assign loaded asset " + field.getName(), e);
                }
            }
            ObjectMap<Object[], AssetDescriptor<?>[]> fieldsToAssetArrays = containersFieldsToAssetArrays.get(assetContainer);
            for (ObjectMap.Entry<Object[], AssetDescriptor<?>[]> arrayEntry : fieldsToAssetArrays) {
                Object[] destinationArray = arrayEntry.key;
                AssetDescriptor<?>[] descriptors = arrayEntry.value;
                for (int i = 0; i < descriptors.length; i++) {
                    destinationArray[i] = get(descriptors[i]);
                }
            }

            if (assetContainer instanceof AssetContainer)
                ((AssetContainer) assetContainer).onAssetsLoaded();
        }

        loadedContainers.addAll(queuedContainers);
        queuedContainers.clear();
    }
    return done;
}
项目:gdxjam-ugg    文件:LoaderUtils.java   
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
    try {
        throw throwable;
    } catch (Throwable e) {
        Logger.getInstance().error(e.getMessage());
        e.printStackTrace();
    }
}
项目:nhglib    文件:Assets.java   
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
    try {
        throw throwable;
    } catch (Throwable throwable1) {
        throwable1.printStackTrace();
    }
}
项目:nhglib    文件:NhgModelLoader.java   
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, P parameters) {
    final Array<AssetDescriptor> deps = new Array();
    ModelData data = loadModelData(file, parameters);
    if (data == null) return deps;

    ObjectMap.Entry<String, ModelData> item = new ObjectMap.Entry<String, ModelData>();
    item.key = fileName;
    item.value = data;

    synchronized (items) {
        items.add(item);
    }

    TextureLoader.TextureParameter textureParameter = (parameters != null)
            ? parameters.textureParameter
            : defaultParameters.textureParameter;

    for (final ModelMaterial modelMaterial : data.materials) {
        if (modelMaterial.textures != null) {
            for (final ModelTexture modelTexture : modelMaterial.textures) {
                String fName = modelTexture.fileName;

                if (fName.contains("/")) {
                    fName = fName.substring(fName.lastIndexOf("/") + 1);
                }

                deps.add(new AssetDescriptor(currentAsset.dependenciesPath + fName, Texture.class, textureParameter));
            }
        }
    }

    return deps;
}
项目:space-travels-3    文件:LoadingScreen.java   
private void loadLevelAsset(
    AssetManager assMan,
    LevelParameters levelParameters,
    String assetPath,
    Class assetClass)
{
    @SuppressWarnings("unchecked")
    AssetDescriptor assetDescriptor =
        new AssetDescriptor(assetPath, assetClass);
    assMan.load(assetDescriptor);
    levelParameters.dependencies.add(assetDescriptor);
}
项目:dice-heroes    文件:ThesaurusLoader.java   
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, ThesaurusLoader.ThesaurusParameter parameter) {
    if (parameter != null && parameter.other.length > 0) {
        Array<AssetDescriptor> descriptors = new Array<AssetDescriptor>();
        for (String depName : parameter.other) {
            descriptors.add(new AssetDescriptor<Thesaurus>(depName, Thesaurus.class));
        }
        return descriptors;
    }
    return null;
}
项目:fabulae    文件:ProjectileTypeLoader.java   
@SuppressWarnings("rawtypes")
private void addSoundDependency(Element soundsElement, String soundElementName, Array<AssetDescriptor> dependencies) {
    Element soundElement = soundsElement.getChildByName(soundElementName);
    if (soundElement != null && soundElement.getChildCount() > 0) {
        for (int i = 0; i < soundElement.getChildCount(); ++i) {
            dependencies.add(new AssetDescriptor<Sound>(Configuration.addModulePath(soundElement.getChild(i).get(XMLUtil.XML_FILENAME)), Sound.class));
        }
    }
}
项目:fabulae    文件:TrapLoader.java   
@SuppressWarnings("rawtypes")
private void addSoundDependency(Element soundsElement, String soundElementName, Array<AssetDescriptor> dependencies) {
    Element soundElement = soundsElement.getChildByName(soundElementName);
    if (soundElement != null && soundElement.getChildCount() > 0) {
        for (int i = 0; i < soundElement.getChildCount(); ++i) {
            dependencies.add(new AssetDescriptor<Sound>(Configuration.addModulePath(soundElement.getChild(i).get(XMLUtil.XML_FILENAME)), Sound.class));
        }
    }
}
项目:fabulae    文件:SkinLoaderWithSounds.java   
@Override
public Skin loadSync (AssetManager manager, String fileName, FileHandle file, SkinParameter parameter) {
    String textureAtlasPath = file.pathWithoutExtension() + ".atlas";
    ObjectMap<String, Object> resources = null;
    if (parameter != null) {
        if (parameter.textureAtlasPath != null){
            textureAtlasPath = parameter.textureAtlasPath;
        }
        if (parameter.resources != null){
            resources = parameter.resources;
        }
    }
    TextureAtlas atlas = manager.get(textureAtlasPath, TextureAtlas.class);
    Skin skin = new SkinWithTrueTypeFonts(atlas);
    if (resources != null) {
        for (Entry<String, Object> entry : resources.entries()) {
            skin.add(entry.key, entry.value);
        }
    }

    for (AssetDescriptor<Sound> sound : sounds) {
        skin.add(sound.file.nameWithoutExtension(), Gdx.audio.newSound(sound.file), Sound.class);
    }

    skin.load(file);
    return skin;
}
项目:fabulae    文件:SkinLoaderWithSounds.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, SkinParameter parameter) {
    sounds = new Array<AssetDescriptor<Sound>>();

    ObjectMap<String, FileHandle> soundFiles = Assets.getAssetFiles(
            file.parent().child("sounds").path(), null, file.type());

    for (FileHandle soundFile : soundFiles.values()) {
        AssetDescriptor<Sound> ad = new AssetDescriptor<Sound>(soundFile, Sound.class);
        sounds.add(ad);
    }

    return super.getDependencies(fileName, file, parameter);
}
项目:RavTech    文件:DummySceneLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, AssetLoaderParameters<Scene> parameter) {
    scene = new Json().fromJson(Scene.class, serializedScene);
    Array<AssetDescriptor> assetDependencies = new Array<AssetDescriptor>();
    for (int i = 0; i < scene.gameObjects.size; i++)
        scene.gameObjects.get(i).load(assetDependencies);
    return assetDependencies;
}
项目:RavTech    文件:PrefabManager.java   
/** Makes a GameObject out of the given string
 * 
 * @param string - the string describing the GameObject
 * @return the GameObject */
public static GameObject makeObject (String string) {
    Json json = new Json();
    GameObject object = json.fromJson(GameObject.class, string);
    @SuppressWarnings("rawtypes")
    Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
    object.load(dependencies);
    for (int i = 0; i < dependencies.size; i++)
        RavTech.files.getAssetManager().load(dependencies.get(i));
    RavTech.files.finishLoading();
    object.finishedLoading();
    return object;
}
项目:RavTech    文件:ProjectLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, AssetLoaderParameters<Project> parameter) {
    project = new Json().fromJson(Project.class, file.readString());
    Array<AssetDescriptor> assetDependencies = new Array<AssetDescriptor>();
    return assetDependencies;
}
项目:RavTech    文件:SceneLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, AssetLoaderParameters<Scene> parameter) {
    scene = new Json().fromJson(Scene.class, file.readString());
    Array<AssetDescriptor> assetDependencies = new Array<AssetDescriptor>();
    for (int i = 0; i < scene.gameObjects.size; i++)
        scene.gameObjects.get(i).load(assetDependencies);
    return assetDependencies;
}
项目:RavTech    文件:SpriteRenderer.java   
@SuppressWarnings("rawtypes")
public SpriteRenderer () {
    this("textures/error.png", 2, 2);
    Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
    load(dependencies);
    RavTech.files.loadAssets(dependencies);
    RavTech.files.finishLoading();
}
项目:RavTech    文件:SpriteRenderer.java   
@Override
public void load (@SuppressWarnings("rawtypes") Array<AssetDescriptor> dependencies) {
    if(!RavTech.files.isLoaded(texturePath)) {
    dependencies.add(new AssetDescriptor<Texture>(texturePath, Texture.class));
    RavTech.files.addDependency(texturePath, this);
    }
}
项目:RavTech    文件:FontRenderer.java   
@Override
public void load (@SuppressWarnings("rawtypes") Array<AssetDescriptor> dependencies) {
    if(!RavTech.files.isLoaded(path)) {
    dependencies.add(new AssetDescriptor<BitmapFont>(path, BitmapFont.class));
    RavTech.files.addDependency(path, this);
    }
}
项目:RavTech    文件:AudioEmitter.java   
@SuppressWarnings("rawtypes")
@Override
public void load (Array<AssetDescriptor> dependencies) {
    AssetDescriptor<Sound> assetDescriptor = new AssetDescriptor<Sound>(filePath, Sound.class);
    Debug.log("LoadSound", filePath);
    dependencies.add(assetDescriptor);
}
项目:RavTech    文件:ScriptComponent.java   
public void setScript (String scriptPath) {
    RavTech.files.addDependency(scriptPath, this);
    if (scriptPath.startsWith("/"))
        scriptPath = scriptPath.substring(1);
    path = scriptPath;
    if (RavTech.files.getAssetManager().isLoaded(path))
        RavTech.files.getAssetManager().unload(path);
    RavTech.files.getAssetManager().load(new AssetDescriptor<String>(path, String.class, new AssetLoaderParameters<String>()));
    RavTech.files.finishLoading();
    finishedLoading();
}
项目: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;
}
项目:cocos-ui-libgdx    文件:CocosLoader.java   
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, CocosParameter parameter) {
    Array<AssetDescriptor> assetDescriptors = new Array<>();
    List<String> list = CocoStudioUIEditor.getResources(file);
    for (String name : list) {
        assetDescriptors.add(new AssetDescriptor(CocoStudioUIEditor.dirName + name, Texture.class));
    }
    return assetDescriptors;
}
项目:libgdxjam    文件:OverlapSceneLoader.java   
@Override
public Array<AssetDescriptor> getDependencies(String fileName,
                                              FileHandle file,
                                              Parameters parameter) {

    Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
    dependencies.add(new AssetDescriptor(parameter.atlas, TextureAtlas.class));
    findSpineAnims(reader.parse(file), dependencies);

    return dependencies;
}
项目:libgdxjam    文件:OverlapSceneLoader.java   
private void findSpineAnims(JsonValue value, Array<AssetDescriptor> dependencies)
{
    if (value.has("composite"))
    {
        findSpineAnims(value.get("composite"), dependencies);
    }
    if (value.has("sComposites"))
    {
        JsonValue composites = value.get("sComposites");

        for (int i = 0; i < composites.size; ++i)
        {
            findSpineAnims(composites.get(i), dependencies);
        }
    }
    if (value.has("sSpineAnimations"))
    {
        JsonValue animations = value.get("sSpineAnimations");

        for (int i = 0; i < animations.size; ++i)
        {
            String animationName = animations.get(i).getString("animationName");

            logger.info("-- Found spine animation: " + animationName);

            String fileWithoutExtension = SPINE_ANIMS_DIR + animationName + "/" + animationName;

            SkeletonDataLoaderParameter skeletonParams = new SkeletonDataLoaderParameter();
            skeletonParams.atlasName = fileWithoutExtension + ".atlas";

            dependencies.add(new AssetDescriptor(
                    fileWithoutExtension + ".json",
                    SkeletonData.class,
                    skeletonParams
                    ));
        }
    }
}
项目:libgdxjam    文件:SkeletonDataLoader.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Array<AssetDescriptor> getDependencies( String fileName, FileHandle file, SkeletonDataLoaderParameter parameter) {
    Array<AssetDescriptor> deps = new Array<AssetDescriptor>();
    deps.add(new AssetDescriptor(parameter.atlasName, TextureAtlas.class));
    return deps;
}
项目:nvlist    文件:PremultTextureLoader.java   
@SuppressWarnings("rawtypes")
@Nullable
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file,
        TextureParameter parameter) {
    return null;
}
项目:nvlist    文件:ColorTextureLoader.java   
@SuppressWarnings("rawtypes")
@Nullable
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file,
        Parameters parameter) {

    return null;
}
项目:gdx-lml    文件:EagerSkinLoader.java   
@Override
@SuppressWarnings("rawtypes") // Raw types due to ugly API.
public Array<AssetDescriptor> getDependencies(final String fileName, final FileHandle file,
        final SkinParameter parameter) {
    if (parameter instanceof EagerSkinParameter && ((EagerSkinParameter) parameter).skin != null) {
        return null;
    }
    return super.getDependencies(fileName, file, parameter);
}
项目:gdx-lml    文件:EagerTextureAtlasLoader.java   
@Override
@SuppressWarnings("rawtypes")
public Array<AssetDescriptor> getDependencies(final String fileName, final FileHandle atlasFile,
        final TextureAtlasParameter parameter) {
    if (parameter instanceof EagerTextureAtlasParameter && ((EagerTextureAtlasParameter) parameter).atlas != null) {
        return null;
    }
    return super.getDependencies(fileName, atlasFile, parameter);
}
项目:libgdx-learnlib    文件:Assets.java   
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
    Gdx.app.error(TAG, "couldn't load asset '" + asset.fileName + "'", (Exception) throwable);
}
项目:nhglib    文件:HDRLoader.java   
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, HDRParams parameter) {
    return null;
}