Example usage for com.badlogic.gdx.assets AssetManager get

List of usage examples for com.badlogic.gdx.assets AssetManager get

Introduction

In this page you can find the example usage for com.badlogic.gdx.assets AssetManager get.

Prototype

public synchronized <T> T get(String fileName, Class<T> type) 

Source Link

Usage

From source file:at.therefactory.jewelthief.Game.java

License:Open Source License

private void loadAssets() {
    AssetManager manager = JewelThief.getInstance().getAssetManager();
    manager.load("audio/sounds/collect.ogg", Sound.class);
    manager.load("audio/sounds/coin.ogg", Sound.class);
    manager.load("audio/sounds/applause.ogg", Sound.class);
    manager.load("audio/sounds/one_blow_from_party_horn.ogg", Sound.class);
    manager.finishLoading();/*  w  w  w . j  a v  a2  s .  c  o m*/
    soundCollectJewel = manager.get("audio/sounds/collect.ogg", Sound.class);
    soundOuch = manager.get("audio/sounds/coin.ogg", Sound.class);
    soundApplause = manager.get("audio/sounds/applause.ogg", Sound.class);
    soundLose = manager.get("audio/sounds/one_blow_from_party_horn.ogg", Sound.class);
}

From source file:at.therefactory.jewelthief.screens.LogoScreen.java

License:Open Source License

public LogoScreen(SpriteBatch batch, ShapeRenderer shapeRenderer, FitViewport viewport,
        OrthographicCamera camera) {/* www  . ja  v  a2  s  . c  om*/
    this.batch = batch;
    this.shapeRenderer = shapeRenderer;
    this.viewport = viewport;
    this.camera = camera;

    spriteThere = new Sprite(new Texture("there.png"));
    spriteFactory = new Sprite(new Texture("factory.png"));
    spriteLibGdxLogo = new Sprite(new Texture("libgdx.png"));

    AssetManager am = JewelThief.getInstance().getAssetManager();
    am.load("audio/sounds/keyboard.ogg", Sound.class);
    am.load("audio/sounds/keyboard_go_back.ogg", Sound.class);
    am.load("audio/sounds/re.ogg", Sound.class);
    am.load("audio/sounds/libgdx.ogg", Music.class);
    am.finishLoading();

    soundTypeTheRefactory = am.get("audio/sounds/keyboard.ogg", Sound.class);
    soundGoBackOnKeyboard = am.get("audio/sounds/keyboard_go_back.ogg", Sound.class);
    soundTypeRe = am.get("audio/sounds/re.ogg", Sound.class);
    musicLibGdxJingle = am.get("audio/sounds/libgdx.ogg", Music.class);

    resetAnimation();
}

From source file:com.badlogic.gdx.rube.test.SpriteRenderer.java

public void addImage(RubeScene _scene, RubeImage _image, AssetManager assetManager) {

    if (_image instanceof RubeImage) {
        RubeImage image = (RubeImage) _image;

        Texture texture = null;//from ww  w . java  2  s . co m
        RubeSprite sprite = null;

        if (assetManager != null) {
            // If the scene uses atlases instead of a bunch of texture we get it instead
            if (_scene.usesAtlas()) {
                TextureAtlas atlas = assetManager.get("data/" + _scene.getAtlasFilePath(0), TextureAtlas.class);
                if (atlas != null) {
                    TextureRegion region = atlas.findRegion(image.file);
                    if (region != null)
                        sprite = new RubeSprite(region, image);
                }
            } else // else we get the textures
            {
                texture = assetManager.get("data/" + image.file, Texture.class);
                sprite = new RubeSprite(texture, image);
            }
        } else // If we don't use the asset manager we create a texture if needed
        {
            texture = textureMap.get("data/" + image.file);
            if (texture == null) {
                texture = new Texture("data/" + image.file);
                textureMap.put("data/" + image.file, texture);
            }
            sprite = new RubeSprite(texture, image);
        }

        if (sprite != null)
            sprites.add(sprite);
    }
}

From source file:com.dongbat.game.util.AssetUtil.java

public static boolean update() {
    AssetManager manager = getManager();
    boolean done = manager.update();

    if (done) {//from ww  w. j  a v  a  2 s . c  o m
        // in-game character
        unitAtlas.put("move", manager.get("texture/unit/move/move.atlas", TextureAtlas.class));
        unitAtlas.put("split", manager.get("texture/unit/split/split.atlas", TextureAtlas.class));
        unitAtlas.put("queen", manager.get("texture/queen/queen.atlas", TextureAtlas.class));
        unitAtlas.put("hot_food", manager.get("texture/food/hot/hot_food.atlas", TextureAtlas.class));
        cold = manager.get("texture/food/cold/cold_food.png", Texture.class);
        move = manager.get("move.png", Texture.class);

        // abilities
        abilities = manager.get("texture/abilities/abilities.atlas", TextureAtlas.class);
        usedAbilities = manager.get("texture/abilities_used/abilities.atlas", TextureAtlas.class);
        cooldown = manager.get("texture/cooldown_button/circle.png", Texture.class);

        // for touchpad joystick
        joyBg = manager.get("texture/joypad/joy_bg.png", Texture.class);
        joyKnob = manager.get("texture/joypad/joy_knob.png", Texture.class);

        // for parallax
        bg00 = manager.get("texture/background/bg00.png", Texture.class);
        bg01 = manager.get("texture/background/bg01.png", Texture.class);
        bg02 = manager.get("texture/background/bg02.png", Texture.class);
        bg03 = manager.get("texture/background/bg03.png", Texture.class);

        // main menu
        title = manager.get("texture/menu/main/name.png", Texture.class);
        singleButton = manager.get("texture/menu/main/single.png", Texture.class);
        multiButton = manager.get("texture/menu/main/multi_disabled.png", Texture.class);
        storyButton = manager.get("texture/menu/main/story_disabled.png", Texture.class);
        pressedSingleButton = manager.get("texture/menu/main/single_down.png", Texture.class);
        pressedMultiButton = manager.get("texture/menu/main/multi_down.png", Texture.class);

        // game ended
        backButton = manager.get("texture/menu/end/back.png");
        backDownButton = manager.get("texture/menu/end/back_down.png");
        endTitle = manager.get("texture/menu/end/title.png");

        // logo
        db = manager.get("db.png", Texture.class);
        logo = manager.get("Bluebird logo.png", Texture.class);
    }
    return done;
}

From source file:com.forerunnergames.peril.client.assets.MultiSourceAssetManager.java

License:Open Source License

@Override
public synchronized <T> T get(final String fileName, final Class<T> type) {
    Arguments.checkIsNotNull(fileName, "fileName");
    Arguments.checkIsNotNull(type, "type");

    final com.badlogic.gdx.assets.AssetManager manager = fileNamesToManagers.get(fileName);

    if (manager == null) {
        throw new IllegalStateException(
                Strings.format("Cannot get asset [{}] because it was not loaded first by {}.", fileName,
                        MultiSourceAssetManager.class.getSimpleName()));
    }//from w w w .  j  a  va2 s.  c o m

    return manager.get(fileName, type);
}

From source file:com.idp.engine.resources.assets.IdpAssetManager.java

private IdpAssetManager() {
    this.man = new AssetManager();
    FileHandleResolver resolver = new InternalFileHandleResolver();
    man.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    man.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));

    this.loadingAssets = new HashMap<String, ArrayList<IdpAsset>>();
    this.pixmaps = new ArrayList<IdpColorPixmap>();
    this.cache = new HashMap<String, PixmapAndTexture>();

    this.callback = new LoadedCallback() {
        @Override//from   ww  w  .ja va  2s .c o  m
        public void finishedLoading(AssetManager assetManager, String fileName, Class type) {
            ArrayList<IdpAsset> list = loadingAssets.remove(fileName);
            if (list != null) {
                Object loaded = assetManager.get(fileName, type);
                for (IdpAsset asset : list) {
                    asset.setAsset(loaded);
                }
            }
        }
    };
}

From source file:com.intrepid.nicge.utilz.animation.AnimationPackLoader.java

@Override
public AnimationPack loadSync(AssetManager manager, String fileName, FileHandle file,
        AnimationPackParameter parameter) {
    byte[] bytes = file.readBytes();
    String json = null;//from ww  w .j  a v a  2 s. c o m
    if (ENCODED)
        json = new String(Base64.getDecoder().decode(bytes));
    else
        json = new String(bytes);
    AnimationPackInfo animationPackInfo = new Json().fromJson(AnimationPackInfo.class, json);

    String texturePath = "resources/textures/" + file.nameWithoutExtension() + ".png";
    Texture texture = manager.get(texturePath, Texture.class);

    return new AnimationPack(animationPackInfo, texture);
}

From source file:com.kotcrab.vis.plugin.spine.runtime.SkeletonDataLoader.java

License:Open Source License

@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file,
        SkeletonDataLoaderParameter parameter) {
    skeletonData = null;//  ww  w  .  j  av a2s  . co  m
    TextureAtlas atlas = manager.get(parameter.atlasPath, TextureAtlas.class);

    String extension = file.extension();
    if (extension.toLowerCase().equals("skel")) {
        SkeletonBinary skeletonBinary = new SkeletonBinary(atlas);
        skeletonBinary.setScale(parameter.scale);
        skeletonData = skeletonBinary.readSkeletonData(resolve(parameter.skeletonPath));
    } else {
        SkeletonJson skeletonJson = new SkeletonJson(atlas);
        skeletonJson.setScale(parameter.scale);
        skeletonData = skeletonJson.readSkeletonData(resolve(parameter.skeletonPath));
    }
}

From source file:com.mangecailloux.pebble.assets.PebbleMusicLoaderParameter.java

License:Apache License

/**
 * @param _userCallback user callback to process the music if needed. It will already be added to the manager.
 *//* w w  w .  j  ava2  s .c om*/
public PebbleMusicLoaderParameter(LoadedCallback _userCallback) {
    super();
    userCallBack = null;

    loadedCallback = new LoadedCallback() {
        @SuppressWarnings("rawtypes")
        @Override
        public void finishedLoading(AssetManager assetManager, String fileName, Class type) {

            if (type == Music.class) {
                // Register the music to the manager is it's not already the case
                if (!Pebble.musics.contains(fileName)) {
                    Music sound = assetManager.get(fileName, Music.class);
                    Pebble.musics.register(fileName, sound);
                }

                // Call the user callback if needed.
                if (userCallBack != null)
                    userCallBack.finishedLoading(assetManager, fileName, type);
            }
        }
    };
}

From source file:com.mangecailloux.pebble.assets.PebbleSoundLoaderParameter.java

License:Apache License

/**
 * @param _userCallback user callback to process the sound if needed. It will already be added to the manager.
 *///w w w .  j  a va2 s .  c  o m
public PebbleSoundLoaderParameter(LoadedCallback _userCallback) {
    super();
    userCallBack = null;

    loadedCallback = new LoadedCallback() {
        @SuppressWarnings("rawtypes")
        @Override
        public void finishedLoading(AssetManager assetManager, String fileName, Class type) {

            if (type == Sound.class) {
                // Register the sound to the manager is it's not already the case
                if (!Pebble.sounds.contains(fileName)) {
                    Sound sound = assetManager.get(fileName, Sound.class);
                    Pebble.sounds.register(fileName, sound);
                }

                // Call the user callback if needed.
                if (userCallBack != null)
                    userCallBack.finishedLoading(assetManager, fileName, type);
            }
        }
    };
}