PXLoader – A JavaScript Preloader for HTML5 Apps
PixelLab has released a JavaScript library to simplify the download of images, sound files and other various assets for HTML5 games called PxLoader.
Here’s a basic example from the site:
// Create the loader and queue our 3 images. Images will not
// begin downloading until we tell the loader to start.
var loader = new PxLoader(),
backgroundImg = loader.addImage('/images/site/missing_thumb.gif'),
treesImg = loader.addImage('/images/site/missing_thumb.gif'),
ufoImg = loader.addImage('/images/site/missing_thumb.gif');
// callback that will be run once images are ready
loader.addCompletionListener(function() {
var canvas = document.getElementById('sample1-canvas'),
ctx = canvas.getContext('2d');
ctx.drawImage(backgroundImg, 0, 0);
ctx.drawImage(treesImg, 0, 104);
ctx.drawImage(ufoImg, 360, 50);
});
// begin downloading images
loader.start();
The source available on GitHub
[Via HTML5Devs.com]