Cocos Creator API

1.3.0

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

LoadingItems

LoadingItems is the queue of items which can flow them into the loading pipeline.
Please don't construct it directly, use LoadingItems.create instead, because we use an internal pool to recycle the queues.
It hold a map of items, each entry in the map is a url to object key value pair.
Each item always contains the following property:

  • id: The identification of the item, usually it's identical to url
  • url: The url
  • type: The type, it's the extension name of the url by default, could be specified manually too.
  • error: The error happened in pipeline will be stored in this property.
  • content: The content processed by the pipeline, the final result will also be stored in this property.
  • complete: The flag indicate whether the item is completed by the pipeline.
  • states: An object stores the states of each pipe the item go through, the state can be: Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE

    Item can hold other custom properties.
    Each LoadingItems object will be destroyed for recycle after onComplete callback
    So please don't hold its reference for later usage, you can copy properties in it though.

map Object

The map of all items.

completed Object

The map of completed items.

totalCount Number

Total count of all items.

completedCount Number

Total count of completed items.

active Boolean

Activated or not.

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

onProgress
(
  • completedCount
  • totalCount
  • item
)

This is a callback which will be invoked while an item flow out the pipeline. You can pass the callback function in LoadingItems.create or set it later.

completedCount Number

The number of the items that are already completed.

totalCount Number

The total number of the items.

item Object

The latest item which flow out the pipeline.

:

loadingItems.onProgress = function (completedCount, totalCount, item) {
     var progress = (100 * completedCount / totalCount).toFixed(2);
     cc.log(progress + '%');
 }

onComplete
(
  • errors
  • items
)

This is a callback which will be invoked while all items is completed, You can pass the callback function in LoadingItems.create or set it later.

errors Array

All errored urls will be stored in this array, if no error happened, then it will be null

items LoadingItems

All items.

:

loadingItems.onComplete = function (errors, items) {
     if (error)
         cc.log('Completed with ' + errors.length + ' errors');
     else
         cc.log('Completed ' + items.totalCount + ' items');
 }

invoke
(
  • key
  • [p1 ]
  • [p2 ]
  • [p3 ]
  • [p4 ]
  • [p5 ]
)

key String
p1 optional Any
p2 optional Any
p3 optional Any
p4 optional Any
p5 optional Any

invokeAndRemove
(
  • key
  • [p1 ]
  • [p2 ]
  • [p3 ]
  • [p4 ]
  • [p5 ]
)

key String
p1 optional Any
p2 optional Any
p3 optional Any
p4 optional Any
p5 optional Any

bindKey
(
  • key
  • [remove =false]
)
Function

key String
remove optional Boolean false

remove callbacks after invoked

:

: Function

the new callback which will invoke all the callbacks binded with the same supplied key

add
(
  • key
  • callback
  • [target ]
)
Boolean

key String
callback Function
target optional Object

can be null

:

: Boolean

whether the key is new

has
(
  • key
  • [callback ]
  • [target ]
)
Boolean

Check if the specified key has any registered callback. If a callback is also specified, it will only return true if the callback is registered.

key String
callback optional Function
target optional Object

:

removeAll
(
  • key
)

Removes all callbacks registered in a certain event type or all callbacks registered with a certain target

key String | Object

The event key to be removed or the target to be removed

remove
(
  • key
  • callback
  • target
)
Boolean

key String
callback Function
target Object

:

: Boolean

removed

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