com.badlogic.gdx.assets.AssetManager Java Examples

The following examples show how to use com.badlogic.gdx.assets.AssetManager. 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 File: GameplayScreen.java    From ud406 with 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 #2
Source File: GameplayScreen.java    From ud406 with 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 #3
Source File: Assets.java    From ud406 with 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 #4
Source File: AMScreen.java    From cocos-ui-libgdx with 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 #5
Source File: DiceHeroes.java    From dice-heroes with 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 #6
Source File: TextureAtlasExercise.java    From ud406 with 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 #7
Source File: DCCLoader.java    From riiablo with 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 #8
Source File: EntityFactory.java    From ninja-rabbit with 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 #9
Source File: GameplayScreen.java    From ud406 with 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 #10
Source File: Examples.java    From Entitas-Java with 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 #11
Source File: GameplayScreen.java    From ud406 with 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 File: GameplayScreen.java    From ud406 with 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 #13
Source File: Assets.java    From ud406 with 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 #14
Source File: GameplayScreen.java    From ud406 with 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);
//        level.initializeDebugLevel();

        level = LevelLoader.load("Level1", gameplayViewport);
        chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal());
    }
 
Example #15
Source File: Assets.java    From ud406 with 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 #16
Source File: Assets.java    From ud406 with 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 #17
Source File: GameplayScreen.java    From ud406 with 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);
//        level.initializeDebugLevel();

        level = LevelLoader.load("Level1", gameplayViewport);
        chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal());
    }
 
Example #18
Source File: BitmapFontLoader.java    From riiablo with Apache License 2.0 5 votes vote down vote up
@Override
public void loadAsync(AssetManager assets, String fileName, FileHandle file, Params params) {
  dc6 = assets.get(name + ".dc6", DC6.class);
  FontTBL tbl = FontTBL.loadFromFile(resolve(name + ".tbl"));
  data = tbl.data(dc6);
  data.blendMode = params != null ? params.blendMode : BlendMode.LUMINOSITY_TINT;
}
 
Example #19
Source File: GameplayScreen.java    From ud406 with 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);
//        level.initializeDebugLevel();

        level = LevelLoader.load("Level1", gameplayViewport);
        chaseCam = new ChaseCam(gameplayViewport.getCamera(), level.getGigaGal());
    }
 
Example #20
Source File: Assets.java    From ud406 with 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 #21
Source File: GameplayScreen.java    From ud406 with 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 #22
Source File: GameplayScreen.java    From ud406 with 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 #23
Source File: Assets.java    From ud406 with 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);
}
 
Example #24
Source File: GameplayScreen.java    From ud406 with 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 #25
Source File: Assets.java    From ud406 with 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 #26
Source File: Assets.java    From ud406 with 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 #27
Source File: GameManager.java    From Pacman_libGdx with MIT License 5 votes vote down vote up
private GameManager() {
    assetManager = new AssetManager();
    assetManager.load("images/actors.pack", TextureAtlas.class);
    assetManager.load("sounds/pill.ogg", Sound.class);
    assetManager.load("sounds/big_pill.ogg", Sound.class);
    assetManager.load("sounds/ghost_die.ogg", Sound.class);
    assetManager.load("sounds/pacman_die.ogg", Sound.class);
    assetManager.load("sounds/clear.ogg", Sound.class);

    assetManager.finishLoading();

    playerSpawnPos = new Vector2();
    ghostSpawnPos = new Vector2();
}
 
Example #28
Source File: GameplayScreen.java    From ud406 with 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 #29
Source File: SimplifiedBeatmapLoader.java    From SIFTrain with MIT License 5 votes vote down vote up
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, BeatmapParameter parameter) {
    beatmaps = new ArrayList<>();
    if (fileName.endsWith(".rs")) {
        loadAsyncStandard(manager, fileName, file, parameter);
    } else if (fileName.endsWith(".osz")) {
        installOsuFiles(manager, fileName, file, parameter);
    } else if (fileName.endsWith(".osu")) {
        convertOsuBeatmap(manager, fileName, file, parameter);
    }
}
 
Example #30
Source File: GameplayScreen.java    From ud406 with 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());
}