Our game is now populated with sound effects, but it will be so much more awesome if we add background music. Since the player will need to keep switching between MainMenuSceen
and GameplayScene
, there is no point in using SKAction
to play sounds, as it won't play correctly or will get truncated each time the scene is changed.
For this purpose, we will have to use Apple's audio visual class called AVFoundation
to help us get around this issue. As you might have guessed, AVFoundation
is a superclass that handles both the audio and video functionalities, so if you want any video to be played in your game (say, for a tutorial), then you can very well use this class—that is why it was created. But let's get back to including the background music in our game.