0
我試圖在我的遊戲中播放加載的.wav文件的SoundEffectInstances,但我聽不到任何聲音。XNA C#SoundEffectInstance - 沒有聲音
我有一個類「ETSound」;爲此每個對象擁有一個聲音。所以一個ETSound對象可能保持「菜單中打開」聲音,另一個可能會保持「坦克射擊」的聲音......等等
反正ETSound構造是這樣的:
public ETSound(SoundEffect se, float volume, float pitch, bool looped, int soundPriority) {
soundTemplate = se;
this.volume = volume;
this.pitch = pitch;
this.looped = looped;
if (soundPriority > 0) {
if (soundPriority > 64) soundPriority = 64;
instanceArray = new SoundEffectInstance[soundPriority];
nextInstanceIndex = 0;
for (int i = 0; i < soundPriority; ++i) {
SoundEffectInstance sei = soundTemplate.CreateInstance();
sei.Volume = volume;
sei.Pitch = pitch;
instanceArray[i] = sei;
}
}
}
這基本上設置一些參數,並根據提供的SoundEffect創建一個音效實例數組。
然後,我打電話ETSound的播放()函數:
public void Play() {
if (instanceArray[nextInstanceIndex].State != SoundState.Stopped) instanceArray[nextInstanceIndex].Stop();
instanceArray[nextInstanceIndex].Play();
if (++nextInstanceIndex >= instanceArray.Length) nextInstanceIndex = 0;
}
然而,沒有任何反應。我什麼也沒聽到。
誰能告訴我發生了什麼事?謝謝。
我知道這是一個愚蠢的問題,但你的揚聲器是開着的,音量正確嗎? – asawyer
是的,我現在正在聽音樂(顯然它已關閉測試)。 – Xenoprimate
好吧,不得不問。 – asawyer