Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

c# - Why does 'if' stop music and won't let me play any new musics in it? and how do I make it work?

SoundPlayer player = new SoundPlayer();
player.SoundLocation =  "C:\Users\tamar\Documents\Visual Studio 2010\Projects\The legend of Omoor\The legend of Omoor\challenger.wav";

SoundPlayer player2 = new SoundPlayer();
player2.SoundLocation = "C:\Users\tamar\Documents\Visual Studio 2010\Projects\The legend of Omoor\The legend of Omoor\challenger.wav";

Console.WriteLine("The legend of Omoor!");
Console.WriteLine("Press any letter to continue.");
Console.ReadLine();

player.Play();

char a;
Console.WriteLine("Click 'x' to use special move: Arad!");
a = char.Parse(Console.ReadLine());

if (a == 'x')
{
    player2.Play();//that's the part where nothing works, neither the first music, nor the second.
}

the music starts playing after I press "any letter to continue". the problem is that the music stops once I choose x, and it doesn't play the new music that I put in the 'if' too. even without the player2.Play(); in the if, it won't play anything.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...