Preload progress

Hi, is there a way to know the current progress of cc.director.preloadScene? I would like to show a loading bar

Hi,

instead of cc.director.preloadScene use cc.loader.load directly, it has progressCallback. Here is the documentation:

http://www.cocos2d-x.org/docs/creator-api/en/classes/loader.html#load

By the way, preloadScene uses cc.loader.load function, here is the sample:

Best regards,
Zsolt

Thanks, seems perfect.
What’s the point of cc.director.preloadScene then? it’s a bit confusing

You’re welcome!

Ermmm… I don’t know… :slight_smile:

Preload scene is useful when you want to swap scenes without showing a loading bar.

You initiate preloadScene during some other part of your game when you know a scene change would be coming soon, such as your player has entered into a zone or initiated a trigger.

Wait, now that I’m trying it I’m not sure this is what I need.
cc.loader.load loads resources by their names, not an entire scene. Do I have to iterate through them manually? How do I get the resource list of another scene?

Hi,

please check the following code:

The cc.loader.load function loads based on the uuid of the Scene.

Best regards,
Zsolt

Got it, basically I simply had to copy preloadScene code. Many thanks!
One more thing: what tells me the current progress in the progress callback?

EDIT
I see there are completedCount and totalCount but total is just 1 (because I pass the whole scene, I guess)

You should know for example the number of Nodes in the Scene file to be able to display some loading bar… Hmmm…