Hey guys, so Im trying to create 2 sounds that will loop continually depending on which scenes they are in in the game (ie if the main game is playing, it plays one song, and if they are on the title scene, credits scene etc it plays a different one). Anyways, I keep getting thrown the error below:
Error 2 Cannot implicitly convert type 'Microsoft.Xna.Framework.Audio.SoundEffectInstance' to 'Microsoft.Xna.Framework.Audio.SoundEffect'
this is my code for trying to load the sounds, I tried following the MSDN example, but they didnt have anything that showed this:
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundeffectinstance.aspx
| gameSounds = new SoundEffect[12]; |
| gameSounds[0] = Content.Load<SoundEffect>("Sounds/backnext"); |
| gameSounds[1] = Content.Load<SoundEffect>("Sounds/backnext2"); |
| gameSounds[2] = Content.Load<SoundEffect>("Sounds/click"); |
| gameSounds[3] = Content.Load<SoundEffect>("Sounds/ending2"); |
| gameSounds[4] = Content.Load<SoundEffect>("Sounds/ending3"); |
| gameSounds[5] = Content.Load<SoundEffect>("Sounds/Endingceo"); |
| gameSounds[6] = Content.Load<SoundEffect>("Sounds/gainlose"); |
| gameSounds[7] = Content.Load<SoundEffect>("Sounds/jail"); |
| gameSounds[8] = Content.Load<SoundEffect>("Sounds/mouseover"); |
| gameSounds[9] = Content.Load<SoundEffect>("Sounds/startgame"); |
| gameSounds[10] = Content.Load<SoundEffect>("Sounds/titleLoop"); |
| gameSounds[11] = Content.Load<SoundEffect>("Sounds/titleLoop"); |
| |
| gameSongs = new SoundEffectInstance[2]; |
| gameSounds[0] = gameSounds[10].CreateInstance(); |
| gameSounds[1] = gameSounds[11].CreateInstance(); |
Im pretty sure my code for playing them is solid, but here it is anyways:
| //iterates through the scenes |
| for (int i = 0; i < Scenes.Length; i++) |
| { |
| //checks to for a null reference |
| if (Scenes[i] != null) |
| { |
| //updates only active scenes |
| if (Scenes[i].getIsActive() == true) |
| { |
| Scenes[i].Update(gameTime, currentPlayer, collision, this); |
| if (i == 3 || i == 4 || i == 5 || i == 6 || i == 7) |
| { |
| this.gameLoopPlaying = true; |
| } |
| else if (i == 0 || i == 1 || i == 2 || i == 8 || i == 11 || i == 12 || i == 13) |
| { |
| this.gameLoopPlaying = false; |
| } |
| } |
| //unloads and sets to null dead scenes |
| if (Scenes[i].getIsDead() == true) |
| { |
| Scenes[i] = null; |
| } |
| } |
| } |
| if (gameLoopPlaying == false && this.gameLoopPlayingPrev == true) |
| { |
| if (gameSongs[1].State == SoundState.Playing) |
| GameSongs[1].Stop(); |
| GameSongs[0].IsLooped = true; |
| GameSongs[0].Play(); |
| } |
| if (gameLoopPlaying == true && this.gameLoopPlayingPrev == false) |
| { |
| if (gameSongs[0].State == SoundState.Playing) |
| GameSongs[0].Stop(); |
| GameSongs[1].IsLooped = true; |
| GameSongs[1].Play(); |
| } |
| gameLoopPlayingPrev = gameLoopPlaying; |
| base.Update(gameTime); |
Thanks for any help
~David