Class cc.Loader
- Defined in: CCLoader.js
- Extends cc.Scene
Constructor Attributes | Constructor Name and Description |
---|---|
A class to pre-load resources before engine start game main loop.
|
Method Summary
Class Detail
cc.Loader()
A class to pre-load resources before engine start game main loop.
Method Detail
-
ctor()Constructor
-
Returns a shared instance of the loader
- Returns:
- {cc.Loader}
-
{Number} getPercentage()Get loading percentage
//example cc.log(cc.Loader.getInstance().getPercentage() + "%");
- Returns:
- {Number}
-
initWithResources(resources, selector, target)init with resources
- Parameters:
- {Array} resources
- {Function|String} selector
- {Object} target
-
onResLoaded()Callback when a resource file loaded.
//example cc.Loader.getInstance().onResLoaded();
-
onResLoadingErr(name)Callback when a resource file load failed.
//example cc.Loader.getInstance().onResLoaded();
- Parameters:
- name
-
Preload resources in the background
//example var g_mainmenu = [ {src:"res/hello.png"}, {src:"res/hello.plist"}, {src:"res/logo.png"}, {src:"res/btn.png"}, {src:"res/boom.mp3"}, ] var g_level = [ {src:"res/level01.png"}, {src:"res/level02.png"}, {src:"res/level03.png"} ] //load a list of resources cc.Loader.preload(g_mainmenu, this.startGame, this); //load multi lists of resources cc.Loader.preload([g_mainmenu,g_level], this.startGame, this);
- Parameters:
- {Array} resources
- {Function|String} selector
- {Object} target
- Returns:
- {cc.Loader}
-
Preload resources async
- Parameters:
- {Array} resources
- {Function|String} selector
- {Object} target
- Returns:
- {cc.Loader}
-
<static> cc.Loader.purgeCachedData(resources)Release the resources from a list
- Parameters:
- {Array} resources
-
releaseResources(resources)release resources from a list
- Parameters:
- resources