Cocos Creator API

1.3.0

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

Pipeline

: cc

A pipeline describes a sequence of manipulations, each manipulation is called a pipe.
It's designed for loading process. so items should be urls, and the url will be the identity of each item during the process.
A list of items can flow in the pipeline and it will output the results of all pipes.
They flow in the pipeline like water in tubes, they go through pipe by pipe separately.
Finally all items will flow out the pipeline and the process is finished.

Pipeline
(
  • pipes
)

Constructor, pass an array of pipes to construct a new Pipeline, the pipes will be chained in the given order.
A pipe is an object which must contain an id in string and a handle function, the id must be unique in the pipeline.
It can also include async property to identify whether it's an asynchronous process.

pipes Array

:

var pipeline = new Pipeline([
     {
         id: 'Downloader',
         handle: function (item, callback) {},
         async: true
     },
     {id: 'Parser', handle: function (item) {}, async: false}
 ]);

insertPipe
(
  • pipe
  • index
)

Insert a new pipe at the given index of the pipeline.
A pipe must contain an id in string and a handle function, the id must be unique in the pipeline.

pipe Object

The pipe to be inserted

index Number

The index to insert

appendPipe
(
  • pipe
)

Add a new pipe at the end of the pipeline.
A pipe must contain an id in string and a handle function, the id must be unique in the pipeline.

pipe Object

The pipe to be appended

flowIn
(
  • items
)

Let new items flow into the pipeline.
Each item can be a simple url string or an object, if it's an object, it must contain id property.
You can specify its type by type property, by default, the type is the extension name in url.
By adding a skips property including pipe ids, you can skip these pipe.
The object can contain any supplementary property as you want.

items Array

:

pipeline.flowIn([
     'res/Background.png',
     {
         id: 'res/scene.json',
         type: 'scene',
         name: 'scene',
         skips: ['Downloader']
     }
 ]);

flowInDeps
(
  • urlList
  • callback
)
Array deprecated

: since v1.3

Let new items flow into the pipeline and give a callback when the list of items are all completed.
This is for loading dependencies for an existing item in flow, usually used in a pipe logic.
For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded
after all its dependencies are loaded, then you will need to use function to flow in all dependencies
found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback).

urlList Array
callback Function

:

: Array

Items accepted by the pipeline

copyItemStates
(
  • srcItem
  • dstItems
)

Copy the item states from one source item to all destination items.
It's quite useful when a pipe generate new items from one source item,
then you should flowIn these generated items into pipeline,
but you probably want them to skip all pipes the source item already go through,
you can achieve it with this API.

For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.

srcItem Object

The source item

dstItems Array | Object

A single destination item or an array of destination items

isFlowing ( ) Boolean deprecated

: since v1.3

Returns whether the pipeline is flowing (contains item) currently.

:

getItems ( ) LoadingItems deprecated

: since v1.3

Returns all items in pipeline.

getItem
(
  • id
)
Object

Returns an item in pipeline.

id Object

The id of the item

:

: Object

removeItem
(
  • id
)
Boolean

Removes an item in pipeline, no matter it's in progress or completed.

id Object

The id of the item

:

: Boolean

succeed or not

clear ( )

Clear the current pipeline, this function will clean up the items.

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