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

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

Introduction

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

Prototype

public synchronized boolean update() 

Source Link

Document

Updates the AssetManager, keeping it loading any assets in the preload queue.

Usage

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  2s  .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 void update() {
    for (final com.badlogic.gdx.assets.AssetManager assetManager : libGdxAssetManagers) {
        assetManager.update();
    }//from www  . j  a v  a2  s. c o m
}

From source file:com.strategames.catchdastars.tests.desktop.libgdx.junit.GdxTestRunner.java

License:Open Source License

@Override
public void run(final RunNotifier notifier) {
    System.out.println("---------------------------------------------------");
    System.out.println(this);
    System.out.println("Starting run " + getDescription());
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
    config.title = "core-test";
    config.width = 504;/*from   w w  w. j av  a2 s.com*/
    config.height = 800;
    config.forceExit = false;

    final GdxTestRunner runner = this;
    LwjglApplication app = null;

    try {
        Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {

            @Override
            public void uncaughtException(Thread t, Throwable e) {
                runner.finished = true;
                EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription());
                testNotifier.addFailure(e);
            }
        });

        /*
         * Gdx.gl was not getting nulled out between tests. It may not be
         * the direct cause, but there was no OpenGL context available after
         * a few runs; null out Gdx.gl and it works again.
         * 
         * The 'correct' solution here is to use a new classloader for every
         * test class, but this works for now.
         */

        Gdx.gl = null;
        System.out.println("Gdx.gl: " + Gdx.gl);
        System.out.println("Thread in TestRunner: " + Thread.currentThread());
        app = new LwjglApplication(new ApplicationListener() {

            @Override
            public void resume() {
            }

            @Override
            public void resize(int width, int height) {
            }

            @Override
            public void render() {
                if (!finished) {
                    System.out.println("Running " + runner.getDescription().getDisplayName());

                    try {
                        System.out.println("Thread in Render: " + Thread.currentThread());
                        runner.actualRun(notifier);
                    } catch (Throwable t) {
                        System.out.println("Throwable: " + t.getMessage());
                    } finally {
                        System.out.println("Finally " + runner.getDescription().getDisplayName());
                        runner.finished = true;
                    }
                }
            }

            @Override
            public void pause() {
            }

            @Override
            public void dispose() {
                System.out.println("Disposing");
            }

            @Override
            public void create() {
                AssetManager assetManager = new AssetManager();

                Textures textures = Textures.getInstance();
                try {
                    textures.addAllToAssetManager(assetManager);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }

                while (!assetManager.update()) {
                }
                ;

                try {
                    textures.setup();
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, config);

        while (!finished) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                System.out.println("Interrupted");
                e.printStackTrace();
            }
        }
    } catch (Throwable t) {
        System.out.println(t.getMessage());
    } finally {
        if (app != null) {
            app.stop();
        }
    }

    System.out.println("Ending run " + getDescription());
}

From source file:com.strategames.catchdastars.tests.desktop.libgdx.junit.ScreenTestClass.java

License:Open Source License

@Override
protected void setupUI(Stage stage) {
    AssetManager assetManager = getGameEngine().getManager();

    Textures textures = Textures.getInstance();
    try {//from  ww w .j a v a 2  s  .  c o m
        textures.addAllToAssetManager(assetManager);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    while (!assetManager.update()) {
    }
    ;

    try {
        textures.setup();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}