Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Help needed with xna/c# error

  • 07-03-2009 03:47PM
    #1
    Registered Users, Registered Users 2 Posts: 6,537 ✭✭✭


    Hey making a game in xna for a project. Im implementing music at the minute.

    Basically I have a title screen no music once the player hit starts the game the music plays no problem. I have 3 lives and at first my music played continuously even if i died so i put in music.Stop(AudioStopOptions.AsAuthored); if my if statement when my lives are gone.

    When i die it send me back to the title screen but for somereason it throws up an error when i start the game again saying InvalidOperationException

    so even though the music.play works at the beginning when i die and am thrown back to the title screen it doesnt??

    protected void StartNewGame()
    {
    _GameStarted = 1;
    _LivesLeft = 3;
    player.ScrollRate = 0;
    _playerScore = 0;
    _GameWave = 0;
    music.Play();


    StartNewWave();
    }

    theres my startnewgamemethod that picks out the music.play as an error ONLY when i loose my 3 lives.

    if (_LivesLeft > 0)
    {
    PlayerKilled();

    StartNewWave();
    }
    else
    {
    music.Stop(AudioStopOptions.AsAuthored);
    _GameStarted = 0;
    _ProcessEvents = 1;
    }

    thats where i stop the music playing if i die.

    Can anyone help??


Comments

  • Closed Accounts Posts: 5,482 ✭✭✭Kidchameleon


    Are you updating your audio engine in the update member? Sounds like your just updating it at certain times... Can you post complete source?


Advertisement