Book Image

Sparrow iOS Game Framework Beginner's Guide

By : Johannes Stein
Book Image

Sparrow iOS Game Framework Beginner's Guide

By: Johannes Stein

Overview of this book

Table of Contents (20 chapters)
Sparrow iOS Game Framework Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Afterword
Index

Time for action – getting audio files to play


Perform the following steps to start the audio engine:

  1. Open our Xcode project if it's not already open.

  2. Switch to the Game.m file.

  3. Inside the initializer, start the audio engine as shown; it should be one of the first few statements:

    [SPAudioEngine start];
  4. Add a dealloc method that stops the audio engine:

    -(void) dealloc
    {
        [SPAudioEngine stop];
    }
  5. Run the example.

When we run this example in the simulator, we might see the following lines in the console:

What just happened?

To play any audio file, we need to start the audio engine at the start of our application, which in our case, is the initializer from the Game class.

There are different operational modes for the audio engine, which influence how the iPod music app will behave when we run our game.

If the audio is muted, the game audio will be muted as well. This is the default operational mode; other modes include the game audio continue even when the device is muted or the iPod music mixes with...