List of usage examples for com.badlogic.gdx.assets AssetManager finishLoading
public void finishLoading()
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(); 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) {/* w ww.j a va 2 s.co m*/ 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:broken.shotgun.throwthemoon.actors.Background.java
License:Open Source License
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);//www. j av a 2s. c o m setHeight(FRAME_HEIGHT); background = new TiledDrawable(animation.getKeyFrame(0f)); }
From source file:broken.shotgun.throwthemoon.actors.Boss.java
License:Open Source License
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;//from ww w . j a va 2 s .c om raging = false; color = Color.WHITE; setColor(color); flipX = false; }
From source file:broken.shotgun.throwthemoon.actors.Enemy.java
License:Open Source License
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;/*from w w w . ja v a2 s . c o m*/ }
From source file:broken.shotgun.throwthemoon.actors.Moon.java
License:Open Source License
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();//from w ww. j a v a 2 s.co m }
From source file:broken.shotgun.throwthemoon.actors.MoonChain.java
License:Open Source License
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());/*from w w w . j a v a 2s .c o m*/ 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()); }
From source file:broken.shotgun.throwthemoon.actors.Player.java
License:Open Source License
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);/* w w w. ja v a 2 s .c o m*/ 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); }
From source file:com.alma42.mapgen.game.Assets.java
License:Apache License
public void init(final AssetManager assetManager) { this.assetManager = assetManager; // set asset manager error handler assetManager.setErrorListener(this); // load texture atlas assetManager.load(Constants.TEXTURE_ATLAS_OBJECTS, TextureAtlas.class); // start loading assets and wait until finished assetManager.finishLoading(); Gdx.app.debug(TAG, "# of assets loaded: " + assetManager.getAssetNames().size); for (final String a : assetManager.getAssetNames()) { Gdx.app.debug(TAG, "asset: " + a); }/* w w w . j a v a 2s . c o m*/ final TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS_OBJECTS); // enable texture filtering for pixel smoothing for (final Texture t : atlas.getTextures()) { t.setFilter(TextureFilter.Linear, TextureFilter.Linear); } // create game resource objects this.bunny = new AssetBunny(atlas); this.rock = new AssetRock(atlas); this.goldCoin = new AssetGoldCoin(atlas); this.feather = new AssetFeather(atlas); this.levelDecoration = new AssetLevelDecoration(atlas); }
From source file:com.badlogic.gdx.spriter.demo.SpriterDemoApp.java
private void changeSpriterFile(SpriterDemoFileHandle file) { AssetManager manager = file.manager; AssetDescriptor<SpriterData> desc = new AssetDescriptor<SpriterData>(file, SpriterData.class); try {/*from w ww. j av a2 s .c o m*/ manager.load(desc); manager.finishLoading(); } catch (GdxRuntimeException ex) { popup("Loading error", ex.getLocalizedMessage()); return; } SpriterData data = manager.get(desc); animators.clear(); for (SpriterEntity entity : data.entities) { // Change toString method for charmaps Array<SpriterCharacterMap> replacements = new Array<SpriterCharacterMap>(); for (SpriterCharacterMap map : entity.characterMaps) { SpriterCharacterMap newMap = new SpriterCharacterMap() { @Override public String toString() { return id + ": " + name; } }; newMap.id = map.id; newMap.name = map.name; newMap.maps = map.maps; replacements.add(newMap); } entity.characterMaps = replacements; SpriterAnimator animator = new SpriterAnimator(entity) { @Override public String toString() { SpriterEntity entity = getEntity(); return entity.id + ": " + entity.name; } }; animator.addAnimationListener(new SpriterAnimationAdapter() { @Override public void onEventTriggered(SpriterAnimator animator, String eventName) { popup("SpriterEvent", eventName); } @Override public void onAnimationFinished(SpriterAnimator animator, SpriterAnimation animation) { if (!animation.looping) animator.play(animation); } }); animators.add(animator); } fileChooser.setSelected(file); entityChooser.setItems(animators); if (animators.size > 0) changeAnimator(animators.first()); }