libgdx——游戏音效

本demo下载地址:http://download.csdn.net/detail/caihongshijie6/6987351






libgdx——游戏音效_第1张图片






libgdx——游戏音效_第2张图片




sound

package com.example.audiotest;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;

public class FirstGame implements ApplicationListener {

	private Sound sound;

	@Override
	public void create() {
		
		sound = Gdx.audio.newSound(Gdx.files.internal("sound.ogg"));
		
		sound.loop();
		sound.play(0.3f);
		
		sound.stop();
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void render() {
		// TODO Auto-generated method stub

	}

	@Override
	public void resize(int arg0, int arg1) {
		// TODO Auto-generated method stub

	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

}



music

package com.example.audiotest;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;

public class FirstGame implements ApplicationListener {

	private Music music;

	@Override
	public void create() {
		music = Gdx.audio.newMusic(Gdx.files.internal("music.ogg"));
		
		music.setLooping(true);
		music.setVolume(0.3f);
		music.play();
		music.pause();
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void render() {
		// TODO Auto-generated method stub

	}

	@Override
	public void resize(int arg0, int arg1) {
		// TODO Auto-generated method stub

	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

你可能感兴趣的:(libgdx——游戏音效)