和发动机中存在声音问题



我正在使用andEngine开发一款游戏。我想为这个游戏添加一个背景音。我试着实现声音,但声音并没有被播放。请帮帮我。这是我的代码:

onLoadEngine()

return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE,
                new FillResolutionPolicy(), this.mCamera).setNeedsSound(true))

onLoadResources()

 Sound bgSound;
 SoundFactory.setAssetBasePath("gfx/");
 this.bgSound = SoundFactory.createSoundFromAsset(this.mEngine.getSoundManager(), this,              "bg.mid");
 bgSound.setLoopCount(-1);
 bgSound.play();

将这两行移动到onCreateScene()方法:

 bgSound.setLoopCount(-1);
 bgSound.play();

此外,调用SoundFactory.createMusicFromAsset而不是SoundFactory.createSoundFromAsset

最新更新