XNA音效

时间:2014-06-02 08:58:18

标签: c# xna

声音效果有点问题。它运行不正常,因为当我播放它时,它会在两秒钟内播放约500000次。看看这里:

SoundEffect thunder;
thunter=Content.Load<SoundEffect>("thunder");

foreach (flash flash in flashes)
   if(flash.visible==true)
       if (time >1 && time <3)
            thunder.Play(); //now it sounds bad because it is played a lot of times.. I want it to be played only once! (the sound is 5 sec long)

1 个答案:

答案 0 :(得分:2)

嗯。可能就这么简单:

foreach (var flash in flashes)
   if (flash.visible && time > 1 && time < 3)
   {
        thunder.Play();
        break; // play sound only once
   }