Is it possible to load resource whenever we need it, not just preload at the start?

I saw the following code

//preload ressources cc.Loader.shareLoader().preload(g_ressources);

I would like to know whether it’s possible to load resource whenever we need it (such as when we switch into a new scene). So we don’t have to load all the game’s resource which may be huge at the first place.

Of course, you may preload them whenever you want.

However, please make sure that the preloading has done before they are displayed.

Thanks Shun Lin!
As tested, I can’t put it anywhere such as in callback function checking for touch event to go to another scene. But I have to put the preload code into onExit() function. Then it will work just fine.

Hey, you may have miss-understand my point.
So here it is, I would like to load multiple times. One for starting period of each scene.
To elaborate more, I do preloading first before going to Scene-A. Then after Scene-A is loaded and displayed successfully, then I touch on screen to transition into scene-B in which before scene-B is displayed, I will do preloading of scene-B. It goes like this.

Is that possible?

Or I should preload everything at the very first time, the same place at the original code has done in cocos2d.js. If this is the case, then HTML5 game should not be that big, all content should be packed up nicely within a limit that not hurt browser and system’s ram that much?

Any suggestion or thoughts are welcomed. Thanks!

It is possible to preload resources on each Scene. You may try it by yourself.

Next step, we plan to write a demo which shows how to preload them, and add LoderScene class into engine.

I tested preloading for each scene, it works fine on Desktop PC.
But for mobile (at least for now devices I have iPad, and WP7), it actually loads and show on screen but suddenly the black screen with cocos2d-x logo with percentage happens. It’s flickering alternatively with the load image. So now, I switched to one-time only preload as I predict around 5-6 MB of the total game’s content will be loaded.