当前位置: 首页>>代码示例>>Java>>正文


Java Music.setVolume方法代码示例

本文整理汇总了Java中com.badlogic.gdx.audio.Music.setVolume方法的典型用法代码示例。如果您正苦于以下问题:Java Music.setVolume方法的具体用法?Java Music.setVolume怎么用?Java Music.setVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.audio.Music的用法示例。


在下文中一共展示了Music.setVolume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Sounds

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
/**
 * Sounds constructor.
 * Plays the background music and initializes the game dependent sounds.
 *
 * @param assetManager Place where the sounds and musics are gotten from.
 */
public Sounds(AssetManager assetManager) {
    this.assetManager = assetManager;
    loadSounds();

    Music music = assetManager.get("music/Artofescapism_-_Three_Star_Sky.mp3");
    music.setVolume(0.5f);
    music.setLooping(true);
    music.play();

    //Initializing the game different sounds
    powerup = assetManager.get("music/item.mp3");
    jump = assetManager.get("music/jump.wav");
    lost = assetManager.get("music/lost.wav");
    won = assetManager.get("music/won.wav");
    water = assetManager.get("music/water.wav");
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:23,代码来源:Sounds.java

示例2: playMusicBeautifully

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
public void playMusicBeautifully(String name, Stage stage) {
    final Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    music.setVolume(0);
    if (!usesMusic) {
        disabledMusics.add(music);
    } else {
        music.play();
    }
    music.setLooping(true);
    playingMusics.add(music);
    Action action = new TemporalAction(5f, Interpolation.linear) {
        @Override protected void update(float percent) {
            music.setVolume(percent * volume);
        }
    };
    stage.addAction(action);
    replaceAction(music, action);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:23,代码来源:SoundManager.java

示例3: stopMusicBeautifully

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
public void stopMusicBeautifully(String name, Stage stage) {
    final Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    final float initialVolume = music.getVolume();
    Action action = new TemporalAction(2f, Interpolation.linear) {
        @Override protected void update(float percent) {
            music.setVolume(initialVolume - percent * initialVolume);
        }

        @Override protected void end() {
            music.stop();
            playingMusics.remove(music);
            disabledMusics.remove(music);
        }
    };
    stage.addAction(action);
    replaceAction(music, action);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:22,代码来源:SoundManager.java

示例4: main

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
public static void main(String[] args) 
{
	LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
	
	new LwjglApplication(new Game(){
		@Override
		public void create() {
			
			// play a music
			Music music = Gdx.audio.newMusic(Gdx.files.classpath("cloudconnected.ogg"));
			music.setVolume(0.3f);
			music.play();
			
			// and a pd patch at the same time
			Pd.audio.create(new PdConfiguration());
			Pd.audio.open(Gdx.files.local("resources/test.pd"));
			
		}}, config);
	
}
 
开发者ID:mgsx-dev,项目名称:gdx-pd,代码行数:21,代码来源:AudioGdxMusicTest.java

示例5: playMusic

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
/**
 * Plays the musix like a baws.
 *
 * @param music
 * @return boolean if the musix failed to play
 */
public boolean playMusic(Music music) {
	if (music == null) {
		currentMusic.stop();
		currentMusic = null;
	}
	if (music.equals(currentMusic)) {
		return false;
	}
	if (currentMusic != null) {
		currentMusic.stop();
	};
	music.play();
	music.setVolume(volume);
	music.setLooping(true);
	currentMusic = music;
	return true;
}
 
开发者ID:Saltosion,项目名称:GladiatorBrawler,代码行数:24,代码来源:Jukebox.java

示例6: initialize

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
public void initialize() {
    for (String name : songNames) {
        songs.add(Gdx.audio.newMusic(Gdx.files.internal("music/" + name + ".mp3")));
    }

    for (Music song : songs) {
        song.setVolume(VOLUME);
        song.setOnCompletionListener(new Music.OnCompletionListener() {
            @Override
            public void onCompletion(Music music) {
                MusicManager.playNextSong();
            }
        });
    }

    songs.get(0).play();
}
 
开发者ID:vs-slavchev,项目名称:Virtual-Evil,代码行数:18,代码来源:MusicManager.java

示例7: playMusic

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
public void playMusic(String musicName, boolean isLooping) {
    Music music = assetManager.get(musicPath + musicName);
    music.setVolume(0.6f);
    if (currentMusic.equals(musicName)) {
        music.setLooping(isLooping);
        if (!music.isPlaying()) {
            music.play();
        }
        return;
    }

    stopMusic();
    music.setLooping(isLooping);
    music.play();
    currentMusic = musicName;
}
 
开发者ID:yichen0831,项目名称:Bomberman_libGdx,代码行数:17,代码来源:GameManager.java

示例8: setMusic

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
/**
 * Set the Game's Music.
 */
private void setMusic() {
    Music music = Gdx.audio.newMusic(Gdx.files.internal("music/Artofescapism_-_Three_Star_Sky.mp3"));
    music.setVolume(0.5f);
    music.setLooping(true);
    music.play();
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:10,代码来源:Armadillo.java

示例9: loadMusic

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
@Override
public Music loadMusic(String fileName,boolean isLoop, float volume)
{
	Music music = Gdx.audio.newMusic(Gdx.files.internal(fileName));
	music.setLooping(true);
	music.setVolume(0.5f);
	return music;
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:9,代码来源:DefaultGameAsset.java

示例10: applyMusicVolume

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
/**
 * Recalculates volume and applies it to registered instances of {@link Music} and {@link Sound}
 */
private void applyMusicVolume() {
    float volume = musicVolume / 100 * masterVolume / 100;
    for (ObjectMap.Values<Music> values = musics.values();
         values.hasNext(); ) {
        Music music = values.next();
        music.setVolume(volume);
    }
}
 
开发者ID:EtherWorks,项目名称:arcadelegends-gg,代码行数:12,代码来源:AudioManager.java

示例11: changeVolume

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
/**
 * change the volume associated with a tag
 * @param tag
 * @param value
 */
public void changeVolume(int tag,float value) {
	if(tags.containsKey(tag)) {
		tags.put(tag, MathUtils.clamp(value, 0f, 1f));
		for(Music m : getMusicByTag(tag)) {
			m.setVolume(tags.get(tag, 1f));
		}
	}else
		KyperBoxGame.error("SoundManager","tag ["+tag+"] not found");
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:15,代码来源:SoundManager.java

示例12: playMusicAsSound

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
public void playMusicAsSound(String name) {
    Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    music.setVolume(volume);
    music.play();
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:10,代码来源:SoundManager.java

示例13: setVolume

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
public void setVolume(float volume) {
    if (volume < 0)
        volume = 0;
    if (volume > 1)
        volume = 1;
    this.volume = volume;
    for (Music music : musics.values()) {
        music.setVolume(volume);
    }
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:11,代码来源:SoundManager.java

示例14: setValues

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
@Override
public void setValues(Music object, int type, float[] values) {
   switch (type) {
      case VOLUME:
         object.setVolume(values[0]);
         break;
   }
}
 
开发者ID:bitbrain,项目名称:braingdx,代码行数:9,代码来源:MusicTween.java

示例15: playSound

import com.badlogic.gdx.audio.Music; //导入方法依赖的package包/类
public void playSound(String src) {
	try {
		Music sound = Gdx.audio.newMusic(new FileHandle("assets/sounds/" + src + ".wav"));
		sound.setVolume(Game.soundVolume);
		sound.play();
	} catch (Exception e) {
		System.out.println("Sound file \"" + src + "\" not found.");
	}
}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:10,代码来源:GameState.java


注:本文中的com.badlogic.gdx.audio.Music.setVolume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。