Game Development Reference
In-Depth Information
function destroyAsteroid(e) {
var asteroid = e.target;
stage.removeChild(asteroid);
asteroid = null;
}
function checkForSpawn() {
if (count == spawnDelay) {
spawnAsteroid();
count = 0;
}
}
function onTick(e) {
count++;
checkForSpawn();
stage.update();
}
Summary
In this chapter, you learned how to use SoundJS to add sounds and music to your games. The robust and easy-to-use
Sound class makes adding sound a breeze, and by installing plug-ins you were able to preload sounds and even play
them on a mobile platform. Asset management was also introduced by creating an asset management class to handle
the loading and accessing of loaded files. In the next chapter, code management and organization will be extended
even further by building a state machine to run your game.
 
Search WWH ::




Custom Search