我正在使用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();
答案 0 :(得分:1)
将这两行移至onCreateScene()
方法:
bgSound.setLoopCount(-1);
bgSound.play();
另外,请致电SoundFactory.createMusicFromAsset
而不是SoundFactory.createSoundFromAsset