本文整理匯總了Java中com.badlogic.gdx.audio.Music.setLooping方法的典型用法代碼示例。如果您正苦於以下問題:Java Music.setLooping方法的具體用法?Java Music.setLooping怎麽用?Java Music.setLooping使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.audio.Music
的用法示例。
在下文中一共展示了Music.setLooping方法的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: 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: 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;
}
}
示例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: 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: stopLooping
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
private void stopLooping() {
if (backgroundMusic) {
Music musicAsset = RapidAsset.INSTANCE.getMusic(music.getResourcePath());
musicAsset.setLooping(false);
return;
}
Sound soundAsset = RapidAsset.INSTANCE.getSound(sound.getResourcePath());
for (long id : soundIds) {
soundAsset.setLooping(id, false);
}
}
示例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: 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);
}
示例14: playIntroMusic
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
public void playIntroMusic() {
if (isSoundOn) {
Music music = assetManager.get("sounds/intro.ogg", Music.class);
music.setLooping(true);
music.play();
}
}
示例15: initSounds
import com.badlogic.gdx.audio.Music; //導入方法依賴的package包/類
public static void initSounds() {
_soundMap.put(SoundId.DOOR_CREAK, Gdx.audio.newSound(Gdx.files.internal("audio/effects/door.mp3")));
_soundMap.put(SoundId.DOOR_LOCKED, Gdx.audio.newSound(Gdx.files.internal("audio/effects/door_locked.mp3")));
_soundMap.put(SoundId.SNOW_CRUNCH, Gdx.audio.newSound(Gdx.files.internal("audio/effects/snowsteps_2.mp3")));
_soundMap.put(SoundId.FLOOR_STEP, Gdx.audio.newSound(Gdx.files.internal("audio/effects/footsteps_floor.mp3")));
_soundMap.put(SoundId.CLICK, Gdx.audio.newSound(Gdx.files.internal("audio/effects/caclick.mp3")));
_soundMap.put(SoundId.UNCLE_GASP, Gdx.audio.newSound(Gdx.files.internal("audio/effects/uncleNoise.mp3")));
_soundMap.put(SoundId.ENGINE_START, Gdx.audio.newSound(Gdx.files.internal("audio/effects/car_ignition.mp3")));
_soundMap.put(SoundId.SCARE, Gdx.audio.newSound(Gdx.files.internal("audio/effects/jump-scare.mp3")));
_musicMap.put(MusicId.MAIN_MENU, Gdx.audio.newMusic(Gdx.files.internal("audio/music/bensound-betterdays.mp3")));
Music dark = Gdx.audio.newMusic(Gdx.files.internal("audio/music/244961__patricklieberkind__dark-ambience.mp3"));
dark.setLooping(true);
_musicMap.put(MusicId.DARK, dark);
Music drone = Gdx.audio.newMusic(Gdx.files.internal("audio/music/144921__thesoundcatcher__deepdrone.mp3"));
drone.setLooping(true);
_musicMap.put(MusicId.DRONE, drone);
Music bedroom = Gdx.audio.newMusic(Gdx.files.internal("audio/music/simpleloops/bedroom.mp3"));
bedroom.setLooping(true);
_musicMap.put(MusicId.BEDROOM, bedroom);
Music cozy = Gdx.audio.newMusic(Gdx.files.internal("audio/music/fireplace.mp3"));
cozy.setLooping(true);
_musicMap.put(MusicId.COZY, cozy);
Music crawlspace = Gdx.audio.newMusic(Gdx.files.internal("audio/music/simpleloops/crawlspace.mp3"));
crawlspace.setLooping(true);
_musicMap.put(MusicId.CRAWLSPACE, crawlspace);
Music howl = Gdx.audio.newMusic(Gdx.files.internal("audio/music/simpleloops/howl.mp3"));
howl.setLooping(true);
_musicMap.put(MusicId.HOWL, howl);
Music wind = Gdx.audio.newMusic(Gdx.files.internal("audio/music/simpleloops/wind.mp3"));
wind.setLooping(true);
_musicMap.put(MusicId.WIND, wind);
}