Java Code Examples for com.badlogic.gdx.assets.AssetManager

The following examples show how to use com.badlogic.gdx.assets.AssetManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ninja-rabbit   Source File: EntityFactory.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new instance of {@link NinjaRabbit}, defining its graphical, audio and physical
 * properties.
 *
 * @param world
 *            The Box2D {@link World} onto which to create the {@link Body} and {@link Fixture}
 *            of the {@link Entity}.
 * @param loader
 *            A {@link BodyEditorLoader} to handle creation of the Entity body and fixtures.
 * @param assets
 *            The {@link AssetManager} from where to extract the graphical and audio resources.
 *            Those resources should be loaded in the manager before calling this method and
 *            won't be disposed.
 * @param status
 *            A reference to the global status of the player to be updated from the changes in
 *            the returned entity inner state.
 * @param observers
 *            An array of event receivers. Events will fire when the active player status
 *            changes (such as losing lives, collecting items, etc.).
 * @return A ready to use instance of a new {@link NinjaRabbit}.
 */
public static Entity createNinjaRabbit(final World world, final BodyEditorLoader loader, final AssetManager assets,
		final CurrentPlayerStatus status, final PlayerStatusObserver... observers) {
	PhysicsProcessor physics = new NinjaRabbitPhysicsProcessor();
	CONTACT_LISTENER.add(physics);
	world.setContactListener(CONTACT_LISTENER);
	GraphicsProcessor graphics = new NinjaRabbitGraphicsProcessor(assets);
	BodyProcessor bodyProcessor = new NinjaRabbitBodyProcessor(world, loader);
	AudioProcessor audio = new NinjaRabbitAudioProcessor(assets);
	PlayerStatusProcessor player = new NinjaRabbitPlayerStatusProcessor(status);
	if (observers != null) {
		for (PlayerStatusObserver o : observers) {
			player.addObserver(o);
		}
	}
	NinjaRabbit ninjaRabbit = new NinjaRabbit(player, bodyProcessor, graphics, physics, audio);

	if (Ouya.isRunningOnOuya()) {
		Controllers.clearListeners();
		Controllers.addListener(new NinjaRabbitControllerProcessor(ninjaRabbit));
	} else {
		Gdx.input.setInputProcessor(new NinjaRabbitInputProcessor(ninjaRabbit));
	}
	return ninjaRabbit;
}
 
Example 2
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 6 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);

    batch = new SpriteBatch();
    chaseCam = new ChaseCam();
    hud = new GigaGalHud();
    victoryOverlay = new VictoryOverlay();
    gameOverOverlay = new GameOverOverlay();

    onscreenControls = new OnscreenControls();

    // TODO: Use Gdx.input.setInputProcessor() to send touch events to onscreenControls
    // TODO: When you're done testing, use onMobile() turn off the controls when not on a mobile device
    if (onMobile()) {
        Gdx.input.setInputProcessor(onscreenControls);
    }

    startNewLevel();
}
 
Example 3
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 6 votes vote down vote up
@Override
    public void show() {
        AssetManager am = new AssetManager();
        Assets.instance.init(am);

        batch = new SpriteBatch();
        gameplayViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

        // TODO: Comment out the debug level
//        level = new Level(gameplayViewport);
//        level.initializeDebugLevel();

        // TODO: Ask the LevelLoader to load Level1
        level = LevelLoader.load("Level1", gameplayViewport);
        chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal());
    }
 
Example 4
Source Project: dice-heroes   Source File: DiceHeroes.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void create() {
    Gdx.app.setLogLevel(Application.LOG_DEBUG);
    Gdx.input.setCatchBackKey(true);
    Gdx.input.setCatchMenuKey(true);
    Config.clearRegions();
    Config.shapeRenderer = new ShapeRenderer();
    Config.assetManager = new AssetManager();
    Config.preferences = new DicePreferences(Gdx.app.getPreferences("com.vlaaad.dice.preferences"), this);
    Tutorial.killAll();

    setState(new IntroState(new IntroState.Callback() {
        @Override public void onEnded() {
            setScale(Config.preferences.getScale());
            setState(new LoadGameResourcesState(new LoadGameResourcesState.Callback() {
                @Override
                public void onResourcesLoaded() {
                    start();
                }
            }));
        }
    }));
}
 
Example 5
Source Project: cocos-ui-libgdx   Source File: AMScreen.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void show() {
    super.show();
    layout = new GlyphLayout();
    font = new NativeFont(new NativeFontPaint(25));
    font.appendText("正在加载...0123456789%");
    font.setColor(Color.BLACK);
    layout.setText(font, "正在加载...100%");

    stage = new Stage(new StretchViewport(1280, 720));

    assetManager = new AssetManager();
    assetManager.setLogger(new Logger("log", Logger.DEBUG));
    assetManager.setLoader(CocosScene.class, new CocosLoader(new InternalFileHandleResolver()));
    assetManager.load("mainscene/MenuScene.json", CocosScene.class);
}
 
Example 6
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 6 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);

    batch = new SpriteBatch();
    chaseCam = new ChaseCam();
    hud = new GigaGalHud();
    victoryOverlay = new VictoryOverlay();
    gameOverOverlay = new GameOverOverlay();

    onscreenControls = new OnscreenControls();
    if (onMobile()) {
        Gdx.input.setInputProcessor(onscreenControls);
    }

    startNewLevel();
}
 
Example 7
Source Project: ud406   Source File: Assets.java    License: MIT License 6 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
    bulletAssets = new BulletAssets(atlas);
    enemyAssets = new EnemyAssets(atlas);
    explosionAssets = new ExplosionAssets(atlas);
    powerupAssets = new PowerupAssets(atlas);
    exitPortalAssets = new ExitPortalAssets(atlas);
    onscreenControlsAssets = new OnscreenControlsAssets(atlas);
}
 
Example 8
Source Project: Entitas-Java   Source File: Examples.java    License: MIT License 6 votes vote down vote up
@Override
public void create() {
    engine = new ExamplesEngine();
    entitas = new Entitas();

    preferencesManager.LOG_LEVEL = LogManager.LOG_DEBUG;
    AssetManager assetsManager = new AssetManager(new TestFileHandleResolver());
    engine.addManager(new AssetsManagerGDX(assetsManager, preferencesManager));
    engine.addManager(new PhysicsManagerGDX(new Vector2(0,-9.8f)));
    engine.addManager(new GUIManagerGDX(new ScreenViewport(),new BitmapFont(), engine));
    engine.addManager(new SceneManagerGDX(engine, entitas));
    engine.addManager(new LogManagerGDX(preferencesManager));
    engine.addManager(new InputManagerGDX(entitas, engine));
    engine.addManager(preferencesManager);

    game = new ExamplesGame(engine, new EventBusGDX(new MBassador()));
    game.init();
    game.pushState(new PlatformExampleState(engine, entitas));

}
 
Example 9
Source Project: ud406   Source File: TextureAtlasExercise.java    License: MIT License 6 votes vote down vote up
@Override
public void create() {
    batch = new SpriteBatch();

    // TODO: Initialize your AssetManager
    assetManager = new AssetManager();

    // TODO: Set this as the AssetManager's error listener
    assetManager.setErrorListener(this);

    // TODO: tell the AssetManager to load the TextureAtlas with name ATLAS
    assetManager.load(ATLAS, TextureAtlas.class);

    // TODO: Call finishLoading() on your AssetManager
    assetManager.finishLoading();

    // TODO: Get the TextureAtlas from the asset manager
    TextureAtlas atlas = assetManager.get(ATLAS);

    // TODO: Populate your AtlasRegion using findRegion() on your Atlas
    standingRight = atlas.findRegion(STANDING_RIGHT);
}
 
Example 10
Source Project: riiablo   Source File: DCCLoader.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public DCC loadSync(AssetManager assets, String fileName, FileHandle file, DCCParameters params) {
  DCC dcc = this.dcc;
  if (dcc == null) {
    dcc = DCC.loadFromFile(file);
  } else {
    this.dcc = null;
  }

  if (params != null) {
    int preload = params.preload;
    if (preload == DCCParameters.PRELOAD_ALL) {
      dcc.loadDirections(params.combineFrames);
    } else if (preload > 0) {
      for (int d = 0; d < dcc.getNumDirections(); d++) {
        if ((preload & (1 << d)) != 0) dcc.loadDirection(d);
      }
    }
  } else {
    dcc.loadDirections(false);
  }

  return dcc;
}
 
Example 11
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);

    batch = new SpriteBatch();
    gameplayViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    level = new Level(gameplayViewport);

    chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal());
}
 
Example 12
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
    bulletAssets = new BulletAssets(atlas);
    enemyAssets = new EnemyAssets(atlas);
    explosionAssets = new ExplosionAssets(atlas);
    powerupAssets = new PowerupAssets(atlas);
}
 
Example 13
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);
    level = new Level();
    batch = new SpriteBatch();
    viewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);
}
 
Example 14
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
    bulletAssets = new BulletAssets(atlas);
    enemyAssets = new EnemyAssets(atlas);
    explosionAssets = new ExplosionAssets(atlas);
    powerupAssets = new PowerupAssets(atlas);
    exitPortalAssets = new ExitPortalAssets(atlas);
}
 
Example 15
Source Project: ninja-rabbit   Source File: GameOverOverlay.java    License: GNU General Public License v2.0 5 votes vote down vote up
public GameOverOverlay(final Batch batch, final AssetManager assets) {
	stage = new Stage(new ScreenViewport(), batch);
	Label.LabelStyle style = new Label.LabelStyle();
	style.fontColor = Color.WHITE;
	style.font = assets.get(Assets.HUD_FONT);
	Label gameOver = new Label(GAME_OVER_TEXT, style);

	Table table = new Table();
	table.setFillParent(true);
	table.add(gameOver).expand();

	stage.addActor(table);
	overlay = new ShapeRenderer();

}
 
Example 16
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
}
 
Example 17
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
    enemyAssets = new EnemyAssets(atlas);
}
 
Example 18
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
    enemyAssets = new EnemyAssets(atlas);
}
 
Example 19
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
}
 
Example 20
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);
    level = new Level();
    batch = new SpriteBatch();
    viewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);
}
 
Example 21
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);

    batch = new SpriteBatch();
    gameplayViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    level = new Level(gameplayViewport);

    chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal());
}
 
Example 22
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
    bulletAssets = new BulletAssets(atlas);
    enemyAssets = new EnemyAssets(atlas);
    explosionAssets = new ExplosionAssets(atlas);
    powerupAssets = new PowerupAssets(atlas);
}
 
Example 23
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);
    level = new Level();
    batch = new SpriteBatch();
    viewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);
}
 
Example 24
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
    bulletAssets = new BulletAssets(atlas);
    enemyAssets = new EnemyAssets(atlas);
    explosionAssets = new ExplosionAssets(atlas);
    powerupAssets = new PowerupAssets(atlas);
}
 
Example 25
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
    bulletAssets = new BulletAssets(atlas);
    enemyAssets = new EnemyAssets(atlas);
    explosionAssets = new ExplosionAssets(atlas);
    powerupAssets = new PowerupAssets(atlas);
    exitPortalAssets = new ExitPortalAssets(atlas);
}
 
Example 26
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);

    batch = new SpriteBatch();
    gameplayViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    level = new Level(gameplayViewport);

    chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal());
}
 
Example 27
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);
    level = new Level();
    batch = new SpriteBatch();
    viewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);
}
 
Example 28
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);

    batch = new SpriteBatch();
    chaseCam = new ChaseCam();
    hud = new GigaGalHud();
    victoryOverlay = new VictoryOverlay();
    gameOverOverlay = new GameOverOverlay();
    startNewLevel();
}
 
Example 29
Source Project: ud406   Source File: Assets.java    License: MIT License 5 votes vote down vote up
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
    assetManager.finishLoading();

    TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
    gigaGalAssets = new GigaGalAssets(atlas);
    platformAssets = new PlatformAssets(atlas);
    bulletAssets = new BulletAssets(atlas);
    enemyAssets = new EnemyAssets(atlas);
    explosionAssets = new ExplosionAssets(atlas);
    powerupAssets = new PowerupAssets(atlas);
}
 
Example 30
Source Project: ud406   Source File: GameplayScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);

    batch = new SpriteBatch();
    gameplayViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    level = new Level(gameplayViewport);

    chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal());
}