当前位置: 首页>>代码示例>>Java>>正文


Java Music类代码示例

本文整理汇总了Java中com.badlogic.gdx.audio.Music的典型用法代码示例。如果您正苦于以下问题:Java Music类的具体用法?Java Music怎么用?Java Music使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Music类属于com.badlogic.gdx.audio包,在下文中一共展示了Music类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: playSongNoStop

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
/**
 * Plays a song without stopping any currently playing songs. This should only be used
 * when we know the current song is about to end, for seamless transitions between
 * introductions and looping portions of songs.
 * @param fileName
 * @param looping
 */
protected void playSongNoStop(final String fileName, final boolean looping) {
    loadSong(fileName);
    Music music = songs.get(fileName);
    currentSong = music;
    currentSongFileName = fileName;
    currentSong.setLooping(looping);
    currentSong.play();
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:16,代码来源:SoundtrackManager.java

示例2: 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

示例3: onInit

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
@Override
protected void onInit(ScreenBasedGame game, AssetManager assetManager) {
    // load assets
    assetManager.load(MUSIC_PATH, Music.class);
    assetManager.load(BACKGROUND_IMAGE_PATH, Texture.class);
    assetManager.finishLoadingAsset(MUSIC_PATH);
    assetManager.finishLoadingAsset(BACKGROUND_IMAGE_PATH);

    // get assets
    this.music = assetManager.get(MUSIC_PATH, Music.class);
    this.bgTexture = assetManager.get(BACKGROUND_IMAGE_PATH, Texture.class);

    // generate fonts
    this.titleFont = BitmapFontFactory.createFont("./data/font/spartakus/SparTakus.ttf", 48, Color.WHITE,
            Color.BLUE, 3);
    // this.font2 =
    // BitmapFontFactory.createFont("./data/font/spartakus/SparTakus.ttf",
    // 48, Color.RED, Color.WHITE, 3);
    this.font1 = BitmapFontFactory.createFont("./data/font/arial/arial.ttf", 18, Color.WHITE);
    this.font2 = BitmapFontFactory.createFont("./data/font/arial/arial-bold.ttf", 24, Color.WHITE, Color.RED, 3);

    // generate credits text array
    try {
        this.generateCreditLines();
    } catch (IOException e) {
        e.printStackTrace();

        // TODO: remove this line and handle exception with exception window
        System.exit(0);
    }

    Gdx.input.setInputProcessor(null);
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:34,代码来源:CreditsScreen.java

示例4: loadAssets

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
private void loadAssets() {
    InternalFileHandleResolver fileHandler = new InternalFileHandleResolver();
    assetManager = new AssetManager(fileHandler);
    assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(fileHandler));

    assetManager.load(SKIN_PATH, Skin.class);
    assetManager.load(MASTER_PATH, TextureAtlas.class);
    assetManager.load(FONT_NORMAL_PATH, FreeTypeFontGenerator.class);
    assetManager.load(FONT_BOLD_PATH, FreeTypeFontGenerator.class);
    assetManager.load(MUSIC_PATH, Music.class);
    assetManager.load(MAIN_MENU_MUSIC_PATH, Music.class);
    assetManager.load(GOOD_PATH, Sound.class);
    assetManager.load(HALF_PATH, Sound.class);
    assetManager.load(BAD_PATH, Sound.class);
    assetManager.finishLoading();
}
 
开发者ID:DurianHLN,项目名称:Polymorph,代码行数:17,代码来源:Polymorph.java

示例5: 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

示例6: CutsceneStoneAge

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
public CutsceneStoneAge(MyGdxGame myGdxGame) {
	this.myGdxGame = myGdxGame;
	batch = myGdxGame.batch;
	sr = myGdxGame.sr;
	viewport = myGdxGame.viewport;
	camera = myGdxGame.camera;
	font = myGdxGame.font;

	particles = new Particles();

	bg = new Sprite(new Texture("sprites/orange.png"));
	girl = new Sprite(new Texture("sprites/girl.png"));
	stone = new Sprite(new Texture("sprites/stein_angemalt.png"));
	hominideSitzend = new Sprite(new Texture("sprites/hominide_sitzend.png"));
	hominideDuckend = new Sprite(new Texture("sprites/hominide_duckend.png"));
	hominideStehend = new Sprite(new Texture("sprites/hominide_stehend.png"));

	assetManager = new AssetManager();
	assetManager.load("music/tusch.mp3", Sound.class);
	assetManager.load("music/5_steinzeit.mp3", Music.class);

	assetManager.finishLoading();

	tusch = assetManager.get("music/tusch.mp3", Sound.class);
	musicStoneAge = assetManager.get("music/5_steinzeit.mp3", Music.class);
}
 
开发者ID:cdetamble,项目名称:nomoore,代码行数:27,代码来源:CutsceneStoneAge.java

示例7: LogoScreen

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
public LogoScreen(SpriteBatch batch, ShapeRenderer shapeRenderer, FitViewport viewport, OrthographicCamera camera) {
    this.batch = batch;
    this.shapeRenderer = shapeRenderer;
    this.viewport = viewport;
    this.camera = camera;

    spriteThere = new Sprite(new Texture("there.png"));
    spriteFactory = new Sprite(new Texture("factory.png"));
    spriteLibGdxLogo = new Sprite(new Texture("libgdx.png"));

    AssetManager am = JewelThief.getInstance().getAssetManager();
    am.load("audio/sounds/keyboard.ogg", Sound.class);
    am.load("audio/sounds/keyboard_go_back.ogg", Sound.class);
    am.load("audio/sounds/re.ogg", Sound.class);
    am.load("audio/sounds/libgdx.ogg", Music.class);
    am.finishLoading();

    soundTypeTheRefactory = am.get("audio/sounds/keyboard.ogg", Sound.class);
    soundGoBackOnKeyboard = am.get("audio/sounds/keyboard_go_back.ogg", Sound.class);
    soundTypeRe = am.get("audio/sounds/re.ogg", Sound.class);
    musicLibGdxJingle = am.get("audio/sounds/libgdx.ogg", Music.class);

    resetAnimation();
}
 
开发者ID:cdetamble,项目名称:jewelthief,代码行数:25,代码来源:LogoScreen.java

示例8: init

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
public static void init() {

        assetManager.setLoader(TiledMap.class, new TmxMapLoader());

        for (Assets.Fonts font : Assets.Fonts.values()) {
            assetManager.load(font.getPath(), BitmapFont.class);
        }
        for (Assets.Textures texture : Assets.Textures.values()) {
            assetManager.load(texture.getPath(), Texture.class);
        }
        for (Assets.Maps map : Assets.Maps.values()) {
            assetManager.load(map.getPath(), TiledMap.class);
        }
        for (Assets.Musics music : Assets.Musics.values()) {
            assetManager.load(music.getPath(), Music.class);
        }
        for (Assets.Sounds sound : Assets.Sounds.values()) {
            assetManager.load(sound.getPath(), Sound.class);
        }
        assetManager.finishLoading();
    }
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:22,代码来源:AssetManager.java

示例9: playIntroTheme

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
public void playIntroTheme()
{
    if(currentMusic!=null)
        currentMusic.stop();
    currentMusic = intro_loop_intro;
    intro_loop_intro.setOnCompletionListener(new Music.OnCompletionListener() {
        @Override
        public void onCompletion(Music music) {
            currentMusic = intro_loop_main;
            currentMusic.setVolume(vol);
            currentMusic.play();
            currentMusic.setVolume(vol);
        }
    });
    currentMusic.setVolume(vol);
    currentMusic.play();
    currentMusic.setVolume(vol);
    nextMusic = currentMusic;
}
 
开发者ID:GGJG2016,项目名称:EvilBunnyGod,代码行数:20,代码来源:AudioManager.java

示例10: playNext

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
public void playNext(){
    System.out.println("next sound");

    Music old = currentMusic;

    if(nextMusic == null){
        nextMusic = currentMusic;
    }
    if(nextMusic == currentMusic)
        return;

    currentMusic=nextMusic;
    currentMusic.setVolume(vol);
    currentMusic.play();
    currentMusic.setVolume(vol);

    old.stop();
    old = null;

}
 
开发者ID:GGJG2016,项目名称:EvilBunnyGod,代码行数:21,代码来源:AudioManager.java

示例11: run

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
public void run() {
	if (challengeAudio != null && challengeAudio.isPlaying()) {
		challengeAudio.setOnCompletionListener(new OnCompletionListener() {
			@Override
			public void onCompletion(Music music) {
				music.setOnCompletionListener(null);
				stage.addAction(actionLoadNextChallengeQuick());
			}
		});
		return;
	}
	// 5-minute check
	if (totalElapsed > maxTime_secs) {
		log("=== SESSION TIME UP!");
		pausedStage.addAction(actionShowCompletedDialog());
		userPause();
		return;
	}
	loadNextChallenge();
}
 
开发者ID:CherokeeLanguage,项目名称:cll1-gdx,代码行数:21,代码来源:LearningSession.java

示例12: loadNewChallengeAudio

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
private void loadNewChallengeAudio(final String newActiveAudioFile) {
	Gdx.app.postRunnable(new Runnable() {
		public void run() {
			if (challengeAudio != null) {
				challengeAudio.stop();
			}
			if (activeAudioFile != null) {
				if (assets.isLoaded(activeAudioFile)) {
					assets.unload(activeAudioFile);
				}
			}
			assets.load(newActiveAudioFile, Music.class);
			assets.finishLoadingAsset(newActiveAudioFile);
			challengeAudio = assets.get(newActiveAudioFile, Music.class);
			challengeAudio.play();
			activeAudioFile = newActiveAudioFile;
		}
	});
}
 
开发者ID:CherokeeLanguage,项目名称:cll1-gdx,代码行数:20,代码来源:LearningSession.java

示例13: 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

示例14: 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);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:22,代码来源:SoundManager.java

示例15: render

import com.badlogic.gdx.audio.Music; //导入依赖的package包/类
@Override
public void render(float delta)
{
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (APP.assets.update() && !assetsLoaded)
    {
        bg = APP.assets.get("backgrounds/map.png", Texture.class);
        bg.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
        APP.loadingScreen2 = new LoadingScreen2(APP, font, bg);
        menuScreenAtlas = APP.assets.get("atlases/menuscreen.pack", TextureAtlas.class);
        APP.menuScreen = new MenuScreen(APP, font, bg, new MenuHud(APP, APP.viewport, APP.batch, menuScreenAtlas.findRegion("giftiz_logo"), menuScreenAtlas.findRegion("giftiz_logo_badge"), menuScreenAtlas.findRegion("giftiz_logo_warning"), menuScreenAtlas.findRegion("title"), menuScreenAtlas.findRegion("play-button-up"), menuScreenAtlas.findRegion("play-button-down"), menuScreenAtlas.findRegion("highscore-button-up"), menuScreenAtlas.findRegion("highscore-button-down")), APP.assets.get("music/epictheme.ogg", Music.class));
        assetsLoaded = true;
        startTime = System.currentTimeMillis();
    }

    if (assetsLoaded && System.currentTimeMillis() - startTime >= 5000)
        APP.setScreen(APP.menuScreen);

    APP.batch.setProjectionMatrix(APP.camera.combined);
    APP.batch.begin();
    font.render(APP.batch, "Loading", Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2, true);
    APP.batch.end();
}
 
开发者ID:NahroTo,项目名称:Fruit-Destroyer,代码行数:26,代码来源:LoadingScreen.java


注:本文中的com.badlogic.gdx.audio.Music类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。