Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by tarrent

Hi Everyone,

I'd like to ask if there's a way where we can run an Impact game even if all assets are not downloaded yet.

Let's say I have an 8MB worth of arts and sound assets for a game. Is it possible to download only 2MB initially then start the game? Other assets which aren't needed by the game on start, say on Level One will be downloaded as the game progresses or before the player reaches Level Two, Three, and so on.

Thank you for your suggestions.

1 decade ago by Joncom

Unless I'm mistaken, what you're trying to do is quite easy.

ig.module('game.entities.example')

.requires('impact.entity')

.defines(function() {

    EntityExample = ig.Entity.extend({

        // This resource is preloaded before the game starts.
        sheet1: new ig.AnimationSheet('media/load-before.png', 28, 28),

        init: function(x, y, settings) {

        	...

        	// This is not preloaded; it's loaded during runtime.
        	sheet2 = new ig.AnimationSheet('media/load-after.png', 28, 28);

        }

        ...

    }

};

1 decade ago by tarrent

Hi Joncom, thanks for your suggestion. I erased loading media in the init() from my vocabulary because none-preloaded media would cause 'media-not-loaded' errors but now I see this as a strategy for my dilemma.

But I wonder is it alright to use ajax (jquery) to load assets in the init() instead of new ig.AnimationSheet()? Thanks.

1 decade ago by Joncom

Yes, AJAX should work fine too. Just so that you know though, you don&039;t have to load media within #init. You can load it anywhere. For example:

ig.module('game.entities.example')

.requires('impact.entity')

.defines(function() {

    EntityExample = ig.Entity.extend({

        ...

        init: function(x, y, settings) {

            ...

        },

        loadMedia: function() {

            // Load a bunch of media once game is already running.

        },

        ...

    }

};

1 decade ago by tarrent

Thanks much for your inputs :)
Page 1 of 1
« first « previous next › last »