Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Creating custom loader tutorial


Recommended Posts

  • 3 months later...

Necro bump. :) @enpu

I don't know if this is a bug or not, but the first addAsset logo is actually necessary for this to work. If you don't call this first (i.e. call addAsset at least once) then all the other addAssets don't work. Well, I don't know if they don't work or not, but I can't use them in-game.

I didn't do any deep debugging into why this is, but this is a curious FYI. I guess the first call sets up some kind of state (global state??) which is used in subsequent calls, so if the first addAsset is tucked inside the scope of a local method, all the assets are loaded within that scope. 


.body(function() {
// Load loader assets
game.addAsset('logo.png'); // <--This one.

game.createClass('PreLoader', 'Loader', {
    init: function() {
    onComplete: function() {
        // Load game assets

        // Set default loader to MyLoader
        game.System.loader = 'MyLoader';
        // Load start scene with the default loader

game.createClass('MyLoader', 'Loader', {
    init: function() {
        this.logo = new game.Sprite('logo.png');
        this.logo.alpha = 0;
    onProgress: function() {
        this.logo.alpha = this.percent / 100;

game.createScene('Main', {
    init: function() {
        var player = new game.Sprite('player.png');



Edit: Otherwise, great example!

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...