2013-04-13 4 views

답변

1

MediaPlayer 클래스에는 Play() 및 Stop() 메서드가 있습니다.

// Variable declaration 
Song menu_song; 
Song game_song; 
bool isInMenu; //I'll use this instead of the gamestate as example 

//In the LoadContent method: 
//remember to add the song to your project. In this case is in 
//a folder called "music" 
Content.Load<Song>("music/menuSongName"); 
Content.Load<Song>("music/gameSongName"); 

//In Update method: 

if (isInMenu) 
{ 
MediaPlayer.Stop(); //Stop the current audio... 
MediaPlayer.Play(menu_song); //...and start playing the next. 
} 
else 
{ 
MediaPlayer.Stop(); //Stop the current audio 
MediaPlayer.Play(game_song); //...and start playing the next. 
} 

나는 당신이 어떤 문제가 있다면 알려주세요,이 코드를 확인하지 않은 : 만약 내가 올바르게 기억

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.mediaplayer.play.aspx http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.mediaplayer.stop.aspx

, 당신은이 작업을 수행 할 수 있습니다 : 여기 당신은 MSDN의 링크입니다 나와 나는 그것을 검사 할 것이다. =) 그리고 그것은 gamestates와 동일합니다. 나는 당신이이 코드를 당신의 필요에 적응시키는 방법을 알 것이라고 생각합니다.

관련 문제