Im trying to make a game for the iPhone that has background music.
So this is how it is laid out:
I have a main menu with music running in the background via AVAudioPlayer (I have made a custom method that gets called every time the view loads).
I have this about button, when you press it it “addSubview:aboutView” s and it does that fine, but then when I press the back button which “addSubview:mainView” s it goes back to the main menu, but plays the same music track, on top of the one thats already playing.
I have tried making a int that ++s every time the viewDidLoad is called thats in an if (someInt > 1){} but that int forgets its value every time, so it still duplicates the music.
Help!
I know this is simple, but I cannot seem to work it out, its just one of those days.
Im trying to make a game for the iPhone that has background music. So
Share
You should restructure your app.
For example this could be one:
App delegate |_ App Main View Controller |_ AVAudioPlayer |_ UINavigationController |_ Start screen |_ Screen #1 |_ Screen #2 |_ etc.