public static void loadMusicAsset(String musicFilenamePath){ if( musicFilenamePath == null || "".equals(musicFilenamePath.trim()) ){ return; } if( assetManager.isLoaded(musicFilenamePath) ){ return; } //load asset if( filePathResolver.resolve(musicFilenamePath).exists() ){ assetManager.setLoader(Music.class, new MusicLoader(filePathResolver)); assetManager.load(musicFilenamePath, Music.class); //Until we add loading screen, just block until we load the map assetManager.finishLoadingAsset(musicFilenamePath); Gdx.app.debug(TAG, "Music loaded!: " + musicFilenamePath); } else{ Gdx.app.debug(TAG, "Music doesn't exist!: " + musicFilenamePath ); } }
/** 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())); }
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); }