本文整理汇总了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);
}