我在XNA中发音,我想将它们添加到字典中,以便我可以随时存储和调用它们。例如,存储跳跃声音,在玩家类别中跳转时调用它。没有添加到字典容器中的声音
下面是代码:
this.soundEffectInfo = new SoundEffectInfo(this, "BackgroundSound", "Assets\\Sounds\\RaceSound", 0.9f, 20, 20, true);
soundManager.add(soundEffectInfo);
soundEffectInfo.SOUNDEFFECT.Play();
this.soundEffectInfo = new SoundEffectInfo(this, "JumpSound", "Assets\\Sounds\\JumpSound", 0.9f, 20, 20, true);
soundManager.add(soundEffectInfo);
soundEffectInfo
是SoundEffectInfo
对象这需要在SoundEffectInstance
。 SoundManager
是这些实例的类容器。
我得到的错误是:
型“System.NullReferenceException”未处理的异常发生在RATEV2.exe
其他信息:对象引用不设置到对象的实例。
你究竟在哪里发生错误?我没有看到代码叫你跳跃声音... – Vogel612