Game Development Reference
In-Depth Information
// A wrapper function for fade()
//
------------------------------------------------------------
function fadeOut(name, fadeTo, speed) {
fade(name, fadeTo, speed, -1);
}
//
-----------------------------------------------------------
// A wrapper function for fade()
//
-----------------------------------------------------------
function fadeIn(name, fadeTo, speed) {
fade(name, fadeTo, speed, 1);
}
//
-----------------------------------------------------------
// The public interface through which the
client can use the class
//
-----------------------------------------------------------
return {
add: addSound,
play: play,
fadeOut: fadeOut,
fadeIn: fadeIn
};
};
Next, we instantiate a global object of this custom SoundFx type, where every sound
clip used in the game is stored. This way, if we want to play any type of sound, we
simply call the play method on this global reference. Take a look at the following
code:
Search WWH ::




Custom Search