public static void bgload() { texcount = 0; texregcount = 0; fontcount = 0; loaderparser.loadindex("asset.items"); Settings.soundvolume = .7f; Settings.musicvolume = .3f; ////////////////////////////////////////////////////////////// textures = new Texture[TextureNames.Count]; textureregions = new TextureRegion[TextureRegionNames.size()]; sounds = new Sound[SoundNames.Count]; music = new Music[MusicNames.Count]; fonts = new FontExtension[2]; music[Settings.musicindex] = new Music(MusicNames[Settings.musicindex]); music[Settings.musicindex].setLooping(true); music[Settings.musicindex].setVolume(Settings.musicvolume); if (Settings.musicEnabled) { music[Settings.musicindex].play(); isMusicPlaying = true; } adjustvolume(Settings.musicvolume, 1); adjustvolume(Settings.soundvolume, 0); //load all textures reported by pack files///////////// int i = 0; while (i < TextureNames.Count) { textures[i] = new Texture(TextureNames[i]); i++; } Assets.loaderp = 60; i = 0; ///////////////////////////////Load fonts////////////////////////////////// while (i < 2) { string[] s = { "font1", "font2" }; int[] w = { 50, 50, 50, 50 }; int x = TexturRegionName.x[(TexturRegionName.texturegionname.IndexOf(s[i]))] + 9; int y = TexturRegionName.y[(TexturRegionName.texturegionname.IndexOf(s[i]))] + 11; fonts[i]=new FontExtension(textures[TextureNames.IndexOf(FontNames[0])],x,y,16,w[i],w[i+2]); i++; } i = 0; Assets.loaderp = 65; //////////////load all textures regions reported by pack files//////////////// while (i < TexturRegionName.texturename.Count) { int x, y, w, h; x = TexturRegionName.x[i]; y = TexturRegionName.y[i]; w = TexturRegionName.sizex[i]; h = TexturRegionName.sizey[i]; textureregions[i] = new TextureRegion(gettexture(TexturRegionName.texturename[i]), x, y, w, h); i++; Assets.loaderp = 65 + 30 * (i * 100 / TexturRegionName.texturename.Count) / 100; } i = 0; Assets.loaderp = 95; ///////////////load all sounds reported by pack files///////////////////////// sounds[0] = new Sound(SoundNames[0]); sounds[1] = new Sound(SoundNames[2]); sounds[2] = new Sound(SoundNames[1]); /*/ while(i<SoundNames.size()) { sounds[i] = new Sound(SoundNames(i)); i++; } //*/ Assets.loaderp = 100; //////////////////////////////////////////Load all Patterns///////////////////////////// }
public static void playSound(Sound sound) { if (Settings.soundEnabled) sound.play(Settings.soundvolume); //sound.play(0.5f); }