2014-09-05 5 views
0

내가 뭘 잘못하고 있니?XNA/MonoGame 소리와 음악이 내 게임 속도를 늦추고 있습니다.

음악 및 음향 효과가 게임 속도를 크게 낮추고 지연과 눈금이 눈에.니다. MonoGame을 사용하고 있습니다.

음악 :

Game1.instance.Stop(); 
Game1.bgEffect.Dispose(); 
Game1.bgEffect = Content.Load<SoundEffect>("../../../../Content/Sound/track" + Player.Age); 
Game1.instance = Game1.bgEffect.CreateInstance(); 
Game1.instance.Play(); 

사운드 효과 :

if (Game1.fireSoundEffect != null) 
{ 
    Game1.fireSoundInstance.Stop(); 
    Game1.fireSoundEffect.Dispose(); 
} 

Game1.fireSoundEffect = Content.Load<SoundEffect>("../../../../Content/Sound/fire" + Player.Age); 
Game1.fireSoundEffect.Play((float)0.3, (float)0.0, (float)0.0); 
Game1.fireSoundInstance = Game1.fireSoundEffect.CreateInstance(); 
Game1.fireSoundInstance.Play(); 

나는 느낌이 난 중 하나를 완전히 객체를 폐기되지 않았거나 실행 인스턴스를 중지하지. 이 문제를 어떻게 해결할 수 있습니까?

답변

2

업데이트 루프에서 콘텐츠 파이프 라인에서 파일을로드하고 개체를 초기화 한 다음 사운드를 모두 동시에 재생하는 것처럼 보입니다.

LoadContent 함수 (또는 다른 init 함수)에서 내용을로드하고 초기화해야합니다. 그런 다음 Update 루프에서 필요한 경우 Play() 함수를 호출하면됩니다.

관련 문제