In this section, we will add one background music file to the game and make it play continuously throughout the game.
We will be needing the bgMusics.mp3
audio file, which is available in the resources folder for the project. Copy and paste the files into the Published-iOS
directory on your system.
As we will modify the physics project from the last chapter, you can create a copy of the project folder and work on the duplicate project. So, after duplicating the project, open it up in Xcode.
Also, we will change the MainScene
filename in the physics project to GameplayScene
as we will use the MainScene
file from Chapter 2, Scenes and Menus, so that when we click on the play button, the actual game will be loaded.
This way we will also have the flexibility to add an options scene, and we can add the volume mute and slider to it.
So, rename the MainScene.m
and MainScene.h
files GameplayScene.m
and GameplayScene.h
, respectively. Change the code to import GameplayScene...