Cocos Creator API

1.1.2

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

LoadingItems

Module: cc

LoadingItems is the manager of items in pipeline.
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.

Properties

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.

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

isCompleted ( ) Boolean

Check whether all items are completed.

returns:

type: Boolean

isItemCompleted
(
  • id
)
Boolean

Check whether an item is completed.

name type description
id String

The item's id.

returns:

type: Boolean

exists
(
  • id
)
Boolean

Check whether an item exists.

name type description
id String

The item's id.

returns:

type: Boolean

getContent
(
  • id
)
Object

Returns the content of an internal item.

name type description
id String

The item's id.

returns:

type: Object

getError
(
  • id
)
Object

Returns the error of an internal item.

name type description
id String

The item's id.

returns:

type: Object

addListener
(
  • key
  • callback
  • target
)
Boolean

Add a listener for an item, the callback will be invoked when the item is completed.

name type description
key String
callback Function

can be null

target Object

can be null

returns:

type: Boolean

whether the key is new

hasListener
(
  • 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.

name type description
key String
callback optional Function
target optional Object

returns:

type: Boolean

remove
(
  • key
  • callback
  • target
)
Boolean

Removes a listener.
It will only remove when key, callback, target all match correctly.

name type description
key String
callback Function
target Object

returns:

type: Boolean

removed

removeAllListeners
(
  • key
)

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

name type description
key String | Object

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

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

Inherited from CallbacksInvoker:

name type description
key String
p1 optional Any
p2 optional Any
p3 optional Any
p4 optional Any
p5 optional Any

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

Inherited from CallbacksInvoker:

name type description
key String
p1 optional Any
p2 optional Any
p3 optional Any
p4 optional Any
p5 optional Any

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

Inherited from CallbacksInvoker:

name type description
key String
remove optional Boolean false

remove callbacks after invoked

returns:

type: Function

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

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

name type description
key String
callback Function
target optional Object

can be null

returns:

type: 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.

name type description
key String
callback optional Function
target optional Object

returns:

type: Boolean

removeAll
(
  • key
)

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

name type description
key String | Object

The event key to be removed or the target to be 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