O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding background music

In this section, we will add one background music file to the game and make it play continuously throughout the game.

Getting ready

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required