XNA change screen when button sound effect ends

79 views Asked by At

I working on platformer game. I got menu screen and few buttons there. I have problem with "StarGame" button, because after click I want to play sound effect first and than move to gamescreen.

My buttonclick event looks like this:

effect.Play(DebuggingVariables.Volume, 0, 0); 
this.MoveToScreen(typeof(GameScreen).FullName);

effect starts to play, but immediatly move to gamescreen.

I'm using FlatRedBall engine.

1

There are 1 answers

0
Joe Shanahan On

You need to get the duration of the sound effect via SoundEffect.Duration and start counting time passed with something like timer += gameTime.ElapsedGameTime.TotalSeconds. Once timer is bigger than the duration, you can then call your MoveToScreen() method.