Chapter 8. Adding Sound FX and Music

We've come a long way by now in the development of the core game logic and mechanics of our prototype game. One thing that you would have noticed to be patently missing, however, is any and all forms of audio. Sound FX and music are important instruments in the hands of a game developer when it comes to sculpting an immersive and stimulating gaming experience. So what are we waiting for? Let's get auditory! In this chapter, we will learn:

  • How Stencyl handles audio
  • How to import sound files in MP3 and OGG formats
  • The difference between sound effects and music in the Stencyl game engine
  • How to play music in our game levels
  • How to trigger sound effects on the fly

Supporting both MP3 and OGG formats

Stencyl supports two basic audio file formats: MP3 and OGG. One could be forgiven for making the assumption that this means we, as Stencyl developers, can choose which file format to use, according to our own preference. However, this assumption would be wrong. In actuality, the file formats are tied to specific target platforms. Here is the breakdown in a nutshell:

  • MP3 is supported by:
    • Adobe Flash (Flash can also utilize OGG, but not through Stencyl, due to the limitations of the OpenFL framework, on which Stencyl is dependent)
  • OGG is supported by:
    • Android
    • iOS
    • Windows
    • Linux
    • OS X

So in essence, MP3 is supported because the Flash targets won't accept any other format. The OGG format is used for everything else. This means two things:

  1. If you're not planning to ever publish your game to Flash, you can stick with OGG and ignore the MP3 format. The only limitation in this scenario is that you won't be able to test the sound for your mobile games in the Flash Player, which is a useful thing to be able to do.
  2. If you are planning to publish to Flash as well as other mobile and/or desktop targets, you will have to provide both the MP3 and OGG versions of your audio files. This may seem like a nuisance, but it actually doesn't take long to convert between the two formats, once you get used to it. This can be done easily, using applications such as Audacity (you can download this free online application from http://audacity.sourceforge.net/).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.199.184