0

我正在使用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();
4

1 回答 1

1

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

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

另外,打电话SoundFactory.createMusicFromAsset而不是SoundFactory.createSoundFromAsset

于 2012-09-05T07:08:00.037 回答