List of usage examples for com.badlogic.gdx.assets AssetManager get
public synchronized <T> T get(AssetDescriptor<T> assetDescriptor)
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();/* w ww. j a v a2 s. com*/ 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); 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();/*from w w w .jav a 2 s. co m*/ 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; 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();/*from w w w .ja v a 2s .c o m*/ 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 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();/*from www.j a va 2 s. c om*/ 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 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();//from www. j av a2 s . c o m texture = manager.get(TEXTURE_FILENAME); texture.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.Repeat); chainPullSfx = manager.get(SFX_CHAIN_PULL_FILENAME); setWidth(texture.getWidth()); 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();/* ww w . j ava 2 s . c om*/ 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); 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();/*from w w w . j a v a 2 s.c o m*/ Gdx.app.debug(TAG, "# of assets loaded: " + assetManager.getAssetNames().size); for (final String a : assetManager.getAssetNames()) { Gdx.app.debug(TAG, "asset: " + a); } 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 {/* w w w .j a v a 2 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()); }
From source file:com.forerunnergames.peril.client.io.MultiAtlasSkinLoader.java
License:Open Source License
@Override public void loadAsync(final AssetManager manager, final String fileName, final FileHandle file, final SkinParameter parameter) { skin = new Skin(); for (final AssetDescriptor<TextureAtlas> descriptor : parameter.getTextureAtlasAssetDescriptors()) { skin.addRegions(manager.get(descriptor)); }/* www . j a v a 2 s.c om*/ }
From source file:com.github.fauu.helix.core.GeometrySetLoader.java
License:Open Source License
protected GeometrySet loadGeometrySet(AssetManager manager, XmlReader.Element root, FileHandle hgsFile) { final int geometrySetId = root.getIntAttribute("id"); final Array<XmlReader.Element> geometryElements = root.getChildrenByName("geometry"); final Geometry[] geometries = new Geometry[geometryElements.size]; int geometryCount = 0; for (XmlReader.Element geometryElement : geometryElements) { final int geometryId = geometryElement.getIntAttribute("id"); final String geometryName = geometryElement.getAttribute("name"); // FIXME: Construct this path elsewhere and not like that final Model geometryModel = manager .get("assets/geometrysets/" + geometrySetId + "/" + geometryId + ".obj"); final Geometry geometry = new Geometry(geometryId, geometryName, geometryModel); geometries[geometryCount] = geometry; geometryCount++;// w ww . jav a2 s.c o m } geometrySet = new GeometrySet(geometrySetId, geometries); return geometrySet; }