本文整理匯總了Java中com.badlogic.gdx.audio.Music.play方法的典型用法代碼示例。如果您正苦於以下問題:Java Music.play方法的具體用法?Java Music.play怎麽用?Java Music.play使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.audio.Music
的用法示例。
在下文中一共展示了Music.play方法的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: initMusic
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
public void initMusic() {
Music music;
switch (level) {
case 0: //第一關
//初始化音樂
music = MyGdxGame.assetManager.getMusic(Constant.LEVEL_0_BGM);
music.setLooping(true);
music.play();
break;
case 1: //第二關
case 2: //第三關
case 3: //第四關
music = MyGdxGame.assetManager.getMusic(Constant.LEVEL_1_BGM);
music.setLooping(true);
music.play();
break;
case 4: //第五關背景音樂
music = MyGdxGame.assetManager.getMusic(Constant.LEVEL_2_BGM);
music.setLooping(true);
music.play();
break;
}
}
示例3: 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);
}
示例4: playMusic
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
private Music playMusic(boolean isLooping, String fullFilePath){
Music music = _queuedMusic.get(fullFilePath);
if( music != null ){
music.setLooping(isLooping);
music.play();
}else if(Assets.isAssetLoaded(fullFilePath)){
music = Assets.getMusicAsset(fullFilePath);
music.setLooping(isLooping);
music.play();
_queuedMusic.put(fullFilePath, music);
}else{
Gdx.app.debug(TAG, "Music not loaded");
return null;
}
return music;
}
示例5: 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);
}
示例6: 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;
}
示例7: doPlay
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
private void doPlay(int loops) {
Music music = musicRef.get();
if (music != null) {
if (loops <= 0) {
music.setOnCompletionListener(null);
} else {
// TODO: Doesn't work on Desktop, unlike Android the completion listener is only called
// when the music ends, not on every loop.
music.setOnCompletionListener(new LoopEndListener());
}
loopsLeft.set(loops);
music.setLooping(loops < 0 || loops > 1);
applyVolume(); // Re-apply volume in case Music object had to be reloaded
music.play();
paused = false;
}
}
示例8: 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;
}
示例9: 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();
}
示例10: play
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
public void play() {
if (backgroundMusic) {
Music musicAsset = RapidAsset.INSTANCE.getMusic(music.getResourcePath());
musicAsset.setLooping(loop);
musicAsset.play();
} else {
Sound soundAsset = RapidAsset.INSTANCE.getSound(sound.getResourcePath());
long id = soundAsset.play();
soundIds.add(id);
soundAsset.setLooping(id, loop);
}
}
示例11: 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();
}
示例12: playMusic
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
@Override
public final void playMusic( int soundId, boolean looping, float volume, float pan ) {
Music sound = music.get( soundId );
if ( sound == null || sound.isPlaying() ) {
return;
}
sound.setPan( pan, volume );
sound.setLooping( looping );
sound.play();
}
示例13: 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.");
}
}
示例14: initMainScene
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
private void initMainScene() {
sceneLoader.loadScene("MainScene");//Load scene data: world physic , resolution, light
addActor(sceneLoader.sceneActor);
elin=sceneLoader.sceneActor.getCompositeById("elin");
marten= sceneLoader.sceneActor.getCompositeById("marten");
gameStageScript = new GameStageScript(this, elin , marten);
sceneLoader.sceneActor.addScript(gameStageScript);
save=new Save();
martenScript=new MartenScript(this);
elinScript= new ElinScript(this, this.getCamera());
elin.addScript(elinScript);
marten.addScript(martenScript);
for(IBaseItem item: sceneLoader.sceneActor.getItems()) {
if(item.getCustomVariables().getFloatVariable("cochonSpeed") != null && item.isComposite()) {
((CompositeItem)item).addScript(new MovingPigScript(this));
}
if(item.getCustomVariables().getFloatVariable("item") != null && item.isComposite()) {
((CompositeItem)item).addScript(new ItemScript(this));
}
if(item.getCustomVariables().getFloatVariable("food") != null && item.isComposite()) {
((CompositeItem)item).addScript(new FoodScript(this));
}
}
Music music = Gdx.audio.newMusic(Gdx.files.internal("Celestial_Aeon_Project_-_Children.mp3"));
music.play();
music.setLooping(true);
}
示例15: resume
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
@Override
public void resume() {
Music music = musicRef.get();
if (music != null) {
music.play();
paused = false;
}
}