Skip to content

Preloading assets

Mark Knol edited this page Oct 18, 2017 · 6 revisions

Displaying a preloader

Make sure you've read Working with assets.

System.loadAssetPack returns a Promise. Its progressChanged signal can be listened on to show a progress bar:

    var loader = System.loadAssetPack(Manifest.fromAssets("bootstrap"));
    loader.progressChanged.connect(function () {
        trace("Download progress: " + (loader.progress/loader.total));
    });
    loader.get(function (pack) {
        // Download complete, use the pack to start the game
    });

Demo project

Take a look at Space Date's preloader for an example of a simple progress bar. Many games will want to show images and sound in their preloader. In this case, create two asset packs, "bootstrap" and "main". "bootstrap" is loaded first and contains only the assets required to display the preloader, while "main" contains all the rest of the game's assets.

To learn all about asset packs, read Working with assets

Clone this wiki locally