Book Image

HTML5 Game Development by Example: Beginner's Guide

By : Seng Hin Mak
Book Image

HTML5 Game Development by Example: Beginner's Guide

By: Seng Hin Mak

Overview of this book

Table of Contents (18 chapters)
HTML5 Game Development by Example Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
9
Building a Physics Car Game with Box2D and Canvas
Index

Time for action – adding sound effects to the Play button


We will start with the code example available in the code bundle. We will have a folder structure similar to the one shown in the following screenshot:

Perform the following set of steps to add sound effects to the Play button:

  1. The index.html file contains the basic structure of the HTML. Now let's add the following code to the body section of the index.html file:

       <div id="game">
         <section id="menu-scene" class="scene">
           <a href="#game"><span>Play</span></a>
         </section>
       </div>
       <audio id="buttonover">
         <source src="media/button_over.aac" />
         <source src="media/button_over.ogg" />
       </audio>
       <audio id="buttonactive">
         <source src="media/button_active.aac" />
         <source src="media/button_active.ogg" />
       </audio>
  2. The HTML file runs successfully with a stylesheet. The file can be found in the code bundle...