Original Post
I'm trying to implement a simple toggle button to turn on/off the music in my game. The code goes something like this: The problem here is if you hold the mouse button down over the button it toggles hundreds of times and does not work effectively. I could perhaps fumble my way through it and use a frame timer or something. Does anyone have a code snippet or resource link for doing this so I don't have to re-invent the wheel? Hopefully something I can re-use in future projects. And something as small and as simple as possible. Thanks Grey
if (Mouse.GetState().LeftButton == XButtonState.Pressed)
{
if (playState == (int)musicState.Playing)
{
playState = (int)musicState.Stopped;
cue.Pause();
}
else
{
playState = (int)musicState.Playing;
cue.Resume();
}
}