本文整理汇总了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");
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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");
}
示例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();
}
示例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);
}
}
示例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;
}
}
示例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.");
}
}