Adding sound into a game
A game can only be complete with different music and sound effects. There can be background music in the game along with sound effects at each action, such as, when the user taps, we can play a sound, and later, we can play a sound when a player hits an obstacle or some other element in the main game. We can also have different music at different levels. Sound effects play a vital role in enhancing the overall gaming experience, as they indulge the user in a holistic gaming experience.
Adding sounds into a Sprite Kit game
There are two ways to add sound effects in a Sprite Kit game:
Using
SKActions
Using the
AVFoundation
framework
Adding sound effects using SKActions
is not efficient, as compared to the AVFoundation
framework. SKActions
has a lot of limitations, such as that one cannot pause or play the sound in the middle of gameplay, and so on. Hence, it is advisable to use AVFoundation
.
Adding sound into our Platformer game
Let's add sound effects in our Platformer...