Jump to content

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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