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.
You need to get the duration of the sound effect via
SoundEffect.Duration
and start counting time passed with something liketimer += gameTime.ElapsedGameTime.TotalSeconds
. Oncetimer
is bigger than the duration, you can then call yourMoveToScreen()
method.