public static void loadSoundAsset(String soundFilenamePath){ if( soundFilenamePath == null || "".equals(soundFilenamePath.trim()) ){ return; } if( assetManager.isLoaded(soundFilenamePath) ){ return; } //load asset if( filePathResolver.resolve(soundFilenamePath).exists() ){ assetManager.setLoader(Sound.class, new SoundLoader(filePathResolver)); assetManager.load(soundFilenamePath, Sound.class); //Until we add loading screen, just block until we load the map assetManager.finishLoadingAsset(soundFilenamePath); Gdx.app.debug(TAG, "Sound loaded!: " + soundFilenamePath); } else{ Gdx.app.debug(TAG, "Sound doesn't exist!: " + soundFilenamePath ); } }
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(); }
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()); 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()); }
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; }
/** Creates a new AssetManager with all default loaders. */ public AssetManager (FileHandleResolver resolver) { setLoader(BitmapFont.class, new BitmapFontLoader(resolver)); setLoader(Music.class, new MusicLoader(resolver)); setLoader(Pixmap.class, new PixmapLoader(resolver)); setLoader(Sound.class, new SoundLoader(resolver)); setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver)); setLoader(Texture.class, new TextureLoader(resolver)); setLoader(Skin.class, new SkinLoader(resolver)); setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver)); setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver)); setLoader(I18NBundle.class, new I18NBundleLoader(resolver)); setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver)); setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver)); setLoader(Model.class, ".obj", new ObjLoader(resolver)); executor = new AsyncExecutor(1); }
public Assets() { textureParameter = new TextureLoader.TextureParameter(); //textureParameter.genMipMaps = true; textureParameter.magFilter = Texture.TextureFilter.Linear; textureParameter.minFilter = Texture.TextureFilter.Linear; resolver = new MaryoFileHandleResolver(); manager = new AssetManager(resolver); particleEffectParameter = new ParticleEffectLoader.ParticleEffectParameter(); particleEffectParameter.imagesDir = resolver.resolve("data/animation/particles"); // set the loaders for the generator and the fonts themselves manager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver)); manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver)); manager.setLoader(ParticleEffect.class, ".p", new ParticleEffectLoader(resolver)); manager.setLoader(Sound.class, ".mp3", new SoundLoader(new InternalFileHandleResolver())); manager.setLoader(Music.class, ".mp3", new MusicLoader(new InternalFileHandleResolver())); }
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); 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); }
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; raging = false; color = Color.WHITE; setColor(color); flipX = false; }
private void loadSounds() { manager.setLoader(Music.class, new MusicLoader(new InternalFileHandleResolver())); manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver())); manager.load(MUSIC_FILENAME, Music.class); manager.load(SFX_TV_ON_FILENAME, Sound.class); manager.finishLoading(); music = manager.get(MUSIC_FILENAME); music.setLooping(true); tvOnSfx = manager.get(SFX_TV_ON_FILENAME); }