HTML and CSS Reference
In-Depth Information
Figure 7-7. Space Raiders playing sounds from two objects
In
canvasApp()
, we will create a couple constants that represent the filenames of the
sounds we want to play, but without the associated extension. We will still retrieve the
extension with a call to
supportedAudioFormat()
, just as we did in the first iteration,
and store that value in the
audioType
variable.
We will also create an array named
sounds
that we will use to hold all the
HTMLAudio
Element
objects we create. This array will tell us how many objects we have created so
we can visually see when all hell breaks loose:
const SOUND_EXPLODE = "explode1";
const SOUND_SHOOT = "shoot1";
var sounds = new Array();