Speeding up asset load times

Hi,

I’m trying to speed up asset load times by not putting all assets in resource.js but using cc.Loader.preloadAsync to load additional assets after the game has started.

This seems to work, but I’m not sure if I’m seeing any large decrease in load times.

Is this likely to help???

Thanks

Roger

        var res = [
            //image
            {type:"plist",src:"res/mc_2.plist"},
            {type:"image",src:"res/mc_2.png"},

            {type:"plist",src:"res/mc_3.plist"},
            {type:"image",src:"res/mc_3.png"},

            {type:"plist",src:"res/mc_4.plist"},
            {type:"image",src:"res/mc_4.png"},

            {type:"plist",src:"res/mc_5.plist"},
            {type:"image",src:"res/mc_5.png"},

            {type:"plist",src:"res/mc_6.plist"},
            {type:"image",src:"res/mc_6.png"},

        ];
        cc.Loader.preloadAsync(res, this.preloadComplete, this);

My CCLoader.js doesn’t even have a preloadAsync function…

This could explain why it’s not doing much for you :slight_smile:

Check the console, is it getting an error?

http://www.cocos2d-x.org/reference/html5-js/symbols/cc.Loader.html

Hi Farmer Joe

The version I downloaded from GitHub last week seems to have that function on line 432

see
https://github.com/cocos2d/cocos2d-html5/blob/master/cocos2d/CCLoader.js

I’m not sure when preloadAsync was added, but it doesnt give any errors and it appears to work, i.e I appear to be able omit resources from the initial preload (ie not put in them in resource.js)

I’ll need to double check, but I thought if I don’t preload, then assets are not available in the main part of a game etc

Ah yeah my bad, the loader class is actually a lot different, and works a lot better!

As for the async loading, it appeared to work as intended for me.

As far as assets not being available if you don’t preload them, I don’t think that is the case, they would just be loaded at the point of use. I’m not positive on that one though.

It supports multi scene resources preloading now.

Please take a look on /Sample/tests or /Samples/games/MoonWarriors.

@Shun Lin

Thanks. I’ll download the new version and take a look at the changes

Cheers

Roger

you can slice up your resource list to only load what is required for the scene to function

this will speed up loading time on launch