當前位置: 首頁>>代碼示例>>Java>>正文


Java Music.setLooping方法代碼示例

本文整理匯總了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");
}
 
開發者ID:AndreFCruz,項目名稱:feup-lpoo-armadillo,代碼行數:23,代碼來源:Sounds.java

示例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;
	}
}
 
開發者ID:heyzqt,項目名稱:libGdx-xiyou,代碼行數:24,代碼來源:Play.java

示例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);
}
 
開發者ID:ratrecommends,項目名稱:dice-heroes,代碼行數:23,代碼來源:SoundManager.java

示例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;
}
 
開發者ID:Mignet,項目名稱:Inspiration,代碼行數:17,代碼來源:AudioManager.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: 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;
    }
}
 
開發者ID:anonl,項目名稱:nvlist,代碼行數:19,代碼來源:NativeAudio.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: 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);
	}
}
 
開發者ID:Radomiej,項目名稱:JavityEngine,代碼行數:13,代碼來源:SoundPlayer.java

示例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);
	}
}
 
開發者ID:Radomiej,項目名稱:JavityEngine,代碼行數:13,代碼來源:SoundPlayer.java

示例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();
}
 
開發者ID:Inari-Soft,項目名稱:inari-firefly-libGDX,代碼行數:13,代碼來源:GdxAudioImpl.java

示例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);
}
 
開發者ID:h-victor,項目名稱:elin-game,代碼行數:30,代碼來源:GameStage.java

示例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();
	}
}
 
開發者ID:igorcrevar,項目名稱:GoingUnder,代碼行數:8,代碼來源:GameManager.java

示例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);
}
 
開發者ID:gjhutchison,項目名稱:pixelhorrorjam2016,代碼行數:42,代碼來源:AudioManager.java


注:本文中的com.badlogic.gdx.audio.Music.setLooping方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。