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

项目:throw-the-moon    文件:Moon.java   
public Moon(final AssetManager manager) {
    manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
    manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
    manager.load(TEXTURE_FILENAME, Texture.class);
    manager.load(SFX_MOON_CRASH_FILENAME, Sound.class);
    manager.finishLoading();

    texture = manager.get(TEXTURE_FILENAME);
    crashSfx = manager.get(SFX_MOON_CRASH_FILENAME);

    currentFrame = new TextureRegion(texture);

    setWidth(currentFrame.getRegionWidth());
    setHeight(currentFrame.getRegionHeight());
    setOrigin(getWidth() / 2, getHeight() / 2);

    reset(); 
}
项目:throw-the-moon    文件:Background.java   
public Background(AssetManager manager) {
    manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
    manager.load(TEXTURE_FILENAME, Texture.class);
    manager.finishLoading();

    texture = manager.get(TEXTURE_FILENAME);

    TextureRegion[] frames = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0];
    animation = new Animation(0.1f, frames[0], frames[1], frames[2]);
    animation.setPlayMode(PlayMode.LOOP);

    setWidth(FRAME_WIDTH);
    setHeight(FRAME_HEIGHT);

    background = new TiledDrawable(animation.getKeyFrame(0f));
}
项目:throw-the-moon    文件:MoonChain.java   
public MoonChain(final AssetManager manager) {
    manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
    manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
    manager.load(TEXTURE_FILENAME, Texture.class);
    manager.load(SFX_CHAIN_PULL_FILENAME, Sound.class);
    manager.finishLoading();

    texture = manager.get(TEXTURE_FILENAME);
    texture.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.Repeat);

    chainPullSfx = manager.get(SFX_CHAIN_PULL_FILENAME);

    setWidth(texture.getWidth());
    setHeight(texture.getHeight() * TILE_COUNT);
    setOrigin(getWidth() / 2, 0);

    // Note: scale is not used in draw for the chain, this is a hack to make easier to put the chain down
    setScale(3f, 3f);

    collisionArea = new Rectangle(getX(), getY(), getWidth(), getHeight());
    position = new Vector2(getX(), getY());
}
项目:throw-the-moon    文件:Enemy.java   
public Enemy(final AssetManager manager) {
    manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
    manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
    manager.load(TEXTURE_FILENAME, Texture.class);
    manager.load(SFX_HIT_FILENAME, Sound.class);
    manager.finishLoading();

    texture = manager.get(TEXTURE_FILENAME);
    regions = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0];
    idle = new Animation(0.1f, regions[0], regions[1], regions[2]);
    idle.setPlayMode(Animation.PlayMode.LOOP);

    hitSfx = manager.get(SFX_HIT_FILENAME);

    currentFrame = idle.getKeyFrame(0.0f);

    setWidth(currentFrame.getRegionWidth());
    setHeight(currentFrame.getRegionHeight());
    setOrigin(getWidth() / 2, getHeight() / 2);

    collisionArea = new Rectangle(50, 0, (int)getWidth() - 100, (int)getHeight());

    health = 5;
}
项目: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);
}
项目:libgdxcn    文件:TmxMapLoader.java   
/** Retrieves TiledMap resource dependencies
 * 
 * @param fileName
 * @param parameter not used for now
 * @return dependencies for the given .tmx file */
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle tmxFile, Parameters parameter) {
    Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
    try {
        root = xml.parse(tmxFile);
        boolean generateMipMaps = (parameter != null ? parameter.generateMipMaps : false);
        TextureLoader.TextureParameter texParams = new TextureParameter();
        texParams.genMipMaps = generateMipMaps;
        if (parameter != null) {
            texParams.minFilter = parameter.textureMinFilter;
            texParams.magFilter = parameter.textureMagFilter;
        }
        for (FileHandle image : loadTilesets(root, tmxFile)) {
            dependencies.add(new AssetDescriptor(image, Texture.class, texParams));
        }
        return dependencies;
    } catch (IOException e) {
        throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e);
    }
}
项目:SMC-Android    文件:Assets.java   
public Assets()
{
    textureParameter = new TextureLoader.TextureParameter();
    //textureParameter.genMipMaps = true;
    textureParameter.magFilter = Texture.TextureFilter.Linear;
    textureParameter.minFilter = Texture.TextureFilter.Linear;

    resolver = new MaryoFileHandleResolver();
    manager = new AssetManager(resolver);

    particleEffectParameter = new ParticleEffectLoader.ParticleEffectParameter();
    particleEffectParameter.imagesDir = resolver.resolve("data/animation/particles");

    // set the loaders for the generator and the fonts themselves
    manager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
    manager.setLoader(ParticleEffect.class, ".p", new ParticleEffectLoader(resolver));
    manager.setLoader(Sound.class, ".mp3", new SoundLoader(new InternalFileHandleResolver()));
    manager.setLoader(Music.class, ".mp3", new MusicLoader(new InternalFileHandleResolver()));
}
项目: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;
}
项目:cachebox3.0    文件:ImageLoader.java   
private void loadAsync() {

        Thread th = new Thread(new Runnable() {

            @Override
            public void run() {

                if (thumbnail)
                    createThumb();
                final TextureLoader tl = new TextureLoader(new AbsoluteFileHandleResolver());
                try {
                    tl.loadAsync(assetManager, ImgName, Gdx.files.absolute(mPath), null);
                    Gdx.app.postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            // Log.info(log, "LoadSync " + mPath + ":" + ImgName);
                            mImageTex = tl.loadSync(assetManager, ImgName, Gdx.files.absolute(mPath), null);
                            Sprite sprite = new Sprite(mImageTex);
                            spriteWidth = sprite.getWidth();
                            spriteHeight = sprite.getHeight();
                            setSprite(sprite, reziseHeight);
                            // Log.info(log, "LoadSync " + mPath + ":" + ImgName + " ready");
                        }
                    });
                } catch (Exception e) {
                    //e.printStackTrace();
                }

            }
        });
        th.start();
    }
项目: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;
}
项目:throw-the-moon    文件:Player.java   
public Player(final AssetManager manager) {
    manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
    manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
    manager.load(TEXTURE_FILENAME, Texture.class);
    manager.load(SFX_HIT_FILENAME, Sound.class);
    manager.load(SFX_DIE_FILENAME, Sound.class);
    manager.finishLoading();

    texture = manager.get(TEXTURE_FILENAME);
    textureRegions = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0];

    idle = new Animation(0.1f, textureRegions[0], textureRegions[1], textureRegions[2]);
    idle.setPlayMode(Animation.PlayMode.LOOP);

    walk = new Animation(0.3f, textureRegions[3], textureRegions[4]);
    walk.setPlayMode(Animation.PlayMode.LOOP);

    attack = new Animation(0.3f, textureRegions[5], textureRegions[6], textureRegions[7]);
    attack.setPlayMode(Animation.PlayMode.NORMAL);

    hitSfx = manager.get(SFX_HIT_FILENAME);
    dieSfx = manager.get(SFX_DIE_FILENAME);

    setWidth(FRAME_WIDTH);
    setHeight(FRAME_HEIGHT);
    setOrigin(getWidth() / 2, getHeight() / 2);

    state = State.IDLE;
    currentFrame = idle.getKeyFrame(0.0f);

    moveTarget = new Vector2(-1, -1);
    position = new Vector2(getX(), getY());
    velocity = new Vector2(0, 0);

    collisionArea = new Rectangle(getX() + 50, getY(), (int)getWidth() - 100, (int)getHeight());
    attackArea = new Rectangle(0, 0, 0, 0);
}
项目:throw-the-moon    文件:Boss.java   
public Boss(final AssetManager manager) {
    manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
    manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
    manager.load(TEXTURE_FILENAME, Texture.class);
    manager.load(SFX_HIT_FILENAME, Sound.class);
    manager.finishLoading();

    texture = manager.get(TEXTURE_FILENAME);
    regions = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0];
    idle = new Animation(0.1f, regions[0], regions[1], regions[2]);
    idle.setPlayMode(Animation.PlayMode.LOOP);

    hitSfx = manager.get(SFX_HIT_FILENAME);

    currentFrame = idle.getKeyFrame(0.0f);

    setWidth(currentFrame.getRegionWidth());
    setHeight(currentFrame.getRegionHeight());
    setOrigin(getWidth() / 2, getHeight() / 2);

    collisionArea = new Rectangle(getX(), getY() + 80, (int) getWidth(), (int) getHeight() - 170);

    health = 50;
    raging = false;
    color = Color.WHITE;
    setColor(color);
    flipX = false;
}
项目:throw-the-moon    文件:StageClearScreen.java   
public StageClearScreen(final ThrowTheMoonGame game) {
       this.manager = new AssetManager();
       this.stage = new Stage(new StretchViewport(WIDTH, HEIGHT));

       manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
       manager.load(TEXTURE_FILENAME, Texture.class);
    manager.load(MUSIC_FILENAME, Music.class);
       manager.finishLoading();

       background = manager.get(TEXTURE_FILENAME);
    music = manager.get(MUSIC_FILENAME);

       Image backgroundImg = new Image(background);
       stage.addActor(backgroundImg);

       Gdx.input.setInputProcessor(stage);

       stage.addListener(new ActorGestureListener() {
        @Override
        public void tap(InputEvent event, float x, float y, int count, int button) {
            music.stop();
            game.setScreen(new GameScreen(game));
            super.tap(event, x, y, count, button);
        }
       });

    music.setLooping(true);
    music.play();
}
项目:GdxDemo3D    文件:GameScene.java   
public GameScene(ModelLoader.ModelParameters modelParameters,
                 TextureLoader.TextureParameter textureParameter,
                 ParticleEffectLoader.ParticleEffectLoadParameter pfxParameter,
                 String pfxPath, String modelPath, String modelExt, ObjectMap<String, GameObjectBlueprint> sharedBlueprints) {
    this.sharedBlueprints = sharedBlueprints;
    this.assets = new BlenderAssetManager(modelParameters, textureParameter, pfxParameter,
            pfxPath, modelPath, modelExt);
}
项目:GdxDemo3D    文件:GameSceneManager.java   
public GameSceneManager(ModelLoader.ModelParameters modelParameters,
                        TextureLoader.TextureParameter textureParameter,
                        ParticleEffectLoader.ParticleEffectLoadParameter pfxParameter,
                        String pfxPath, String modelPath, String modelExt) {
    this.modelPath = modelPath;
    this.modelExt = modelExt;
    this.pfxPath = pfxPath;

    this.modelParameters = modelParameters;
    this.textureParameter = textureParameter;
    this.pfxParameter = pfxParameter;
}
项目:GdxDemo3D    文件:BlenderAssetManager.java   
public BlenderAssetManager(
        ModelLoader.ModelParameters modelParameters,
        TextureLoader.TextureParameter textureParameter,
        ParticleEffectLoader.ParticleEffectLoadParameter pfxParameter,
        String pfxPath, String modelPath, String modelExt) {
    this.modelExt = modelExt;
    this.modelPath = modelPath;
    this.pfxPath = pfxPath;

    this.modelParameters = modelParameters;
    this.textureParameter = textureParameter;
    this.pfxParameter = pfxParameter;
}
项目:CodeBase    文件:AnimationExtendedLoader.java   
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file,
        AnimationExtendedParameter parameter) {
    Array<AssetDescriptor> deps = new Array();
    TextureLoader.TextureParameter params = new TextureParameter();
    params.format = parameter.format;
    params.genMipMaps = parameter.genMipMaps;
    params.minFilter = parameter.minFilter;
    params.magFilter = parameter.magFilter;
    params.wrapU = parameter.wrapU;
    params.wrapV = parameter.wrapV;
    deps.add(new AssetDescriptor(parameter.filename, Texture.class, params));
    return deps;
}
项目:libgdxcn    文件:AssetManagerTest.java   
public void create () {
    Gdx.app.setLogLevel(Application.LOG_ERROR);

    Resolution[] resolutions = {new Resolution(320, 480, ".320480"), new Resolution(480, 800, ".480800"),
        new Resolution(480, 856, ".480854")};
    ResolutionFileResolver resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), resolutions);
    manager = new AssetManager();
    manager.setLoader(Texture.class, new TextureLoader(resolver));
    manager.setErrorListener(this);
    load();
    Texture.setAssetManager(manager);
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), false);
}
项目:droidtowers    文件:TowerAssetManager.java   
public static MemoryTrackingAssetManager assetManager() {
    if (assetManager == null) {
        assetManager = new MemoryTrackingAssetManager(new FileResolverMultiplexer());
        if (TowerConsts.DEBUG) {
            assetManager.getLogger().setLevel(Logger.ERROR);
        }

        Texture.setAssetManager(assetManager);

        try {
            assetList = TowerGameService.instance().getObjectMapper().readValue(Gdx.files.internal("assets.json").read(), AssetList.class);

            ensureAssetsAreLoaded();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        TextureLoader.TextureParameter parameter = new TextureLoader.TextureParameter();
        parameter.genMipMaps = true;
        parameter.minFilter = MipMapNearestNearest;
        parameter.magFilter = Linear;
        assetManager.load(checkForHDPI("elevator/shaft.png"), Texture.class, parameter);
        assetManager.load(checkForHDPI("elevator/empty.png"), Texture.class, parameter);

        defaultSkin = new Skin(Gdx.files.internal("default-skin.json"));
        makeCustomGUISkin();
    }

    return assetManager;
}
项目: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);
}
项目:nhglib    文件:NhgModelLoader.java   
public ModelParameters() {
    textureParameter = new TextureLoader.TextureParameter();
    textureParameter.minFilter = textureParameter.magFilter = Texture.TextureFilter.Linear;
    textureParameter.wrapU = textureParameter.wrapV = Texture.TextureWrap.Repeat;
}
项目:Quilly-s-Castle    文件:Utils.java   
public static void loadTextureAsset(String filePath) {
loadAsset(filePath, Texture.class, new TextureLoader(fileResolver));
   }
项目:origin    文件:Material.java   
public Material(ModelDesc.Material material)
{
    _castShadows = material.castShadows;
    _receiveShadows = material.receiveShadows;
    _outline = material.outline;

    TextureLoader.TextureParameter parameter = new TextureLoader.TextureParameter();

    String filter = material.filter;
    if (Utils.isEmpty(filter) || filter.equalsIgnoreCase("linear"))
    {
        parameter.minFilter = Texture.TextureFilter.Linear;
        parameter.magFilter = Texture.TextureFilter.Linear;
    }
    else if (filter.equalsIgnoreCase("nearest"))
    {
        parameter.minFilter = Texture.TextureFilter.Nearest;
        parameter.magFilter = Texture.TextureFilter.Nearest;
    }

    if (!Utils.isEmpty(material.diffuse))
    {
        Main.getAssetManager().load(Config.MODELS_DIR + material.diffuse, Texture.class, parameter);
    }

    if (!Utils.isEmpty(material.normal))
    {
        Main.getAssetManager().load(Config.MODELS_DIR + material.normal, Texture.class, parameter);
    }

    if (!Utils.isEmpty(material.specular))
    {
        Main.getAssetManager().load(Config.MODELS_DIR + material.specular, Texture.class, parameter);
    }

    Main.getAssetManager().finishLoading();

    if (!Utils.isEmpty(material.diffuse))
    {
        _diffuse = Main.getAssetManager().get(Config.MODELS_DIR + material.diffuse, Texture.class);
    }
    if (!Utils.isEmpty(material.normal))
    {
        _normal = Main.getAssetManager().get(Config.MODELS_DIR + material.normal, Texture.class);
    }
    if (!Utils.isEmpty(material.specular))
    {
        _specular = Main.getAssetManager().get(Config.MODELS_DIR + material.specular, Texture.class);
    }
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
public HeadlessModelParameters() {
    textureParameter = new TextureLoader.TextureParameter();
    textureParameter.minFilter = textureParameter.magFilter = Texture.TextureFilter.Linear;
    textureParameter.wrapU = textureParameter.wrapV = Texture.TextureWrap.Repeat;
}
项目:ead    文件:URLTextureLoader.java   
public URLTextureLoader(FileHandleResolver resolver) {
    super(resolver);
    textureLoader = new TextureLoader(resolver);
}