Libgdx android后退关闭声音?

时间:2015-08-15 18:34:32

标签: android libgdx

当我点击平板电脑后退游戏结束时。当我点击开始图标时,我的游戏回来了,但声音没有播放。我知道Android上的Libgdx中的声音和音乐存在一些问题。如何管理这个问题? 知道我的简历方法是空的。

public class MyGdxGame extends Game {

MenuScreen menuScreen;
GameScreen gameScreen;
About gameOverScreen;

private AdsController adsController;

public MyGdxGame(AdsController adsController){
    this.adsController = adsController;}

public MyGdxGame(){}


@Override
public void create() {
    menuScreen = new MenuScreen(this);
    gameScreen = new GameScreen(this);
    gameOverScreen = new About(this);
    AssetsLoader.load();
    adsController.showBannerAd();
    setScreen(new MenuScreen(this));
}

@Override
public void dispose(){
    super.dispose();
    AssetsLoader.dispose();
}

public class AssetsLoader {
public static Texture texture, bg, ground, play;

static Music music = Gdx.audio.newMusic(Gdx.files.internal("musicbackground.mp3"));


public static Sound soundPunch = Gdx.audio.newSound(Gdx.files.internal("Strong_Punch-Mike_Koenig-574430706.mp3"));

public static Sound soundSlide = Gdx.audio.newSound(Gdx.files.internal("slide.mp3"));

public static Sound soundJump = Gdx.audio.newSound(Gdx.files.internal("jump.mp3"));

...

public static void load() {

    music.setVolume(0.5f);
    music.setLooping(true);
    music.play();

    play = new Texture(Gdx.files.internal("buttons/play.png"));
...

音乐一直在循环播放。声音在特定情况下从游戏的其他部分初始化,例如跳跃。

 @Override
public void resize(int width, int height) {
    Gdx.app.log("GameScreen", "resizing");
}

@Override
public void show() {
    Gdx.app.log("GameScreen", "show called");
}

@Override
public void hide() {
    Gdx.app.log("GameScreen", "hide called");
}

@Override
public void pause() {
    Gdx.app.log("GameScreen", "pause called");

}

@Override
public void resume() {
    Gdx.app.log("GameScreen", "resume called");


}

@Override
public void dispose() {
    // Leave blank
}

0 个答案:

没有答案