HTML and CSS Reference
In-Depth Information
To start building your dependencies, or the files your engine is dependent on, navigate to
the assets folder. Inside create a file called animation.js using Paul Irish's requestAn-
imationFrame() shown in the following listing ( http://mng.bz/h9v9 ).
Listing 9.3. animation.js—Requesting animation and intervals
window . requestAnimFrame = ( function () {
return window . requestAnimationFrame ||
window . webkitRequestAnimationFrame ||
window . mozRequestAnimationFrame
||
window . oRequestAnimationFrame
||
window . msRequestAnimationFrame
||
function ( callback ) {
window . setTimeout ( callback , 1000 / 60 );
};
})();
John Resig's simple JavaScript inheritance
Because your engine requires you to create objects that can be modified, tweaked, and in-
herited on the fly, you need an extendable class. The problem is that classes usually require
a robust library like prototype.js because JavaScript doesn't natively support them. To keep
your engine's file size and dependencies limited, we're using a slightly modified version of
John Resig's Simple JavaScript Inheritance script ( http://ejohn.org/blog/simple-javascript-
inheritance/ ) . Insert a modified version of John Resig's script from the following listing
into a file called classes.js in the assets folder.
Search WWH ::




Custom Search