Class cc.Loader
Extends
cc.Class.
Defined in: CCLoader.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
A class to pre-load resources before engine start game main loop.
|
| Field Attributes | Field Name and Description |
|---|---|
|
status when res loading error
|
|
|
status when resources loading success
|
|
|
status when res loading
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
cc.Loader.getInstance()
Share Loader
|
|
For loading percentage
You can use this method to create a custom loading screen.
|
|
|
Check the loading status
|
|
|
Callback when a resource file loaded.
|
|
|
onResLoadingErr(name)
Callback when loading resource error
|
|
|
preload(res)
Pre-load the resources before engine start game main loop.
|
Field Detail
onerror
status when res loading error
//example
cc.Loader.getInstance().onerror = function () {
//do something
};
onload
status when resources loading success
//example
cc.Loader.getInstance().onload = function () {
cc.AppController.shareAppController().didFinishLaunchingWithOptions();
};
onloading
status when res loading
//example
cc.Loader.getInstance().onloading = function () {
cc.LoaderScene.getInstance().draw();
};
Method Detail
<static>
{cc.Loader}
cc.Loader.getInstance()
Share Loader
- Returns:
- {cc.Loader}
{Number}
getProgressBar()
For loading percentage
You can use this method to create a custom loading screen.
//example cc.log(cc.Loader.getInstance().getProgressBar() + "%");
- Returns:
- {Number}
isLoadedComplete()
Check the loading status
onResLoaded()
Callback when a resource file loaded.
//example cc.Loader.getInstance().onResLoaded();
onResLoadingErr(name)
Callback when loading resource error
//example cc.Loader.getInstance().onResLoadingErr(name);
- Parameters:
- {String} name
preload(res)
Pre-load the resources before engine start game main loop.
There will be some error without pre-loading resources.
//example
var res = [
{type:"image", src:"hello.png"},
{type:"tmx", src:"hello.tmx"}
]
cc.Loader.getInstance().preload(res);
- Parameters:
- {object} res