我在 Game1 的 Draw() 中有以下代码。但是,只有在我按下程序的关闭按钮时才会播放音乐。如果没有,我应该把 MediaPlayer.Play() 放在哪里?normS、fastS、slowS、playing 都是 Song 类型。如果你需要我澄清什么,尽管问。
if (stateS == "normal")
{
if (!MediaPlayer.Equals(playing, normS))
{
playing = normS;
}
spriteBatch.Draw(norm, pos, Color.White);
}
else if (stateS == "fast")
{
if (!MediaPlayer.Equals(playing, fastS))
{
playing = fastS;
}
spriteBatch.Draw(fast, pos, Color.White);
}
else if (stateS == "slow")
{
if (!MediaPlayer.Equals(playing, slowS))
{
playing = slowS;
}
spriteBatch.Draw(slow, pos, Color.White);
}
MediaPlayer.Play(playing);