Cocos Creator API

0.7.1

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

AssetLibrary

Module: cc

The asset library which managing loading/unloading assets in project.

Properties

_uuidToAsset object private

Caches uuid to all loaded assets in scenes.

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Methods

loadAsset
(
  • uuid
  • callback
  • options
)
private

name type description
uuid String
callback LoadCallback

the callback function once load finished

  • error String
    null or the error info
  • data Asset
    the loaded asset or null
options Object
  • readMainCache Boolean
    Default is true. If false, the asset and all its depends assets will reload and create new instances from library.
  • writeMainCache Boolean
    Default is true. If true, the result will cache to AssetLibrary, and MUST be unload by user manually.
  • existingAsset Asset
    load to existing asset, this argument is only available in editor
  • recordAssets Boolean
    Default is false. If true, tracking statistics associated with the assets which needs to preload(All the assets contains "urls" but dont have "_rawFiles")
  • deserializeInfo deserialize.Details
    specified a DeserializeInfo object if you want, this parameter is only available in editor.

queryAssetInfo
(
  • uuid
  • callback
)

name type description
uuid String
callback Function
  • error Error
  • url String
    the url of raw asset or imported asset
  • raw Boolean
    indicates whether the asset is raw asset
  • ctorInEditor Function
    the actual type of asset, used in editor only

_loadAssetByUuid
(
  • uuid
  • callback
  • handle
  • [existingAsset ]
)
private

name type description
uuid String
callback LoadCallback

the callback to receive the asset, can be null

  • error String
    null or the error info
  • data Asset
    the loaded asset or null
handle LoadingHandle

the loading context which reserves all relevant parameters

existingAsset optional Asset

load to existing asset, this argument is only available in editor

loadJson
(
  • json
  • callback
  • [dontCache =false]
  • [recordAssets =false]
)
LoadingHandle private

name type description
json String | Object
callback LoadCallback
  • error String
    null or the error info
  • data Asset
    the loaded asset or null
dontCache optional Boolean false

If false, the result will cache to AssetLibrary, and MUST be unload by user manually.

recordAssets optional Boolean false

是否统计新加载的需要让场景 preload 的 asset(所有包含 raw file 后缀名的 asset 并且不含 rawType 属性的 asset)

returns:

type: LoadingHandle

_deserializeWithDepends
(
  • json
  • url
  • uuid
  • callback
  • handle
  • [existingAsset ]
)
private

name type description
json String | Object
url String
uuid String
callback LoadCallback
  • error String
    null or the error info
  • data Asset
    the loaded asset or null
handle Object

the loading context which reserves all relevant parameters

existingAsset optional Asset

existing asset to reload

getAssetByUuid
(
  • uuid
)
Asset private

Get the exists asset by uuid.

name type description
uuid String

returns:

type: Asset

the existing asset, if not loaded, just returns null.

init
(
  • options.libraryPath
  • options.mountPaths
  • [options.rawAssets ]
  • [options.rawAssetsBase ]
)

init the asset library

name type description
options.libraryPath String

能接收的任意类型的路径,通常在编辑器里使用绝对的,在网页里使用相对的。

options.mountPaths Object

mount point of actual urls for raw assets (only used in editor)

options.rawAssets optional Object

uuid to raw asset's urls (only used in runtime)

options.rawAssetsBase optional String

base of raw asset's urls (only used in runtime)

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index