Book Image

Learning Cocos2d-JS Game Development

By : Emanuele Feronato
Book Image

Learning Cocos2d-JS Game Development

By: Emanuele Feronato

Overview of this book

Table of Contents (18 chapters)
Learning Cocos2d-JS Game Development
Credits
Foreword
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
9
Creating Your Own Blockbuster Game – A Complete Match 3 Game
Index

Preloading sounds


Preloading sounds is exactly the same as preloading graphic assets. In the assets folder, there are two mp3 files: loop.mp3, which is a short loop used as background music, and bang.mp3, which is an Uzi sound effect. Remember in your final project, you will have to include the WAV and OGG files as well in order to ensure the largest compatibility possible among different browsers in various devices.

The loadassets.js file will include the array of sounds to preload:

var gameResources = [
  "assets/bang.mp3",
  "assets/loop.mp3"
];

Now, let's create a menu to play with sounds and music.