Pipeline 类型

模块: cc 父模块: cc

pipeline 描述了一系列的操作,每个操作都被称为 pipe。
它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。
一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。
它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。
最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。

索引

方法
  • constructor 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。
  • insertPipe 在给定的索引位置插入一个新的 pipe。
  • insertPipeAfter 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。
  • appendPipe 添加一个新的 pipe 到 pipeline 尾部。
  • flowIn 让新的 item 流入 pipeline 中。
  • copyItemStates 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。
  • getItem 根据 id 获取一个 item
  • removeItem 移除指定的已完成 item。
  • clear 清空当前 pipeline,该函数将清理 items。

Details

方法

constructor

构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。
一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。
它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。

meta description
定义于 cocos2d/core/load-pipeline/pipeline.js:112
参数列表
示例
var pipeline = new Pipeline([
     {
         id: 'Downloader',
         handle: function (item, callback) {},
         async: true
     },
     {id: 'Parser', handle: function (item) {}, async: false}
 ]);
insertPipe

在给定的索引位置插入一个新的 pipe。
一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。

meta description
定义于 cocos2d/core/load-pipeline/pipeline.js:156
参数列表
  • pipe Object The pipe to be inserted
  • index Number The index to insert
insertPipeAfter

!en Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline. !zh 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。

meta description
定义于 cocos2d/core/load-pipeline/pipeline.js:199
参数列表
  • refPipe Object An existing pipe in the pipeline.
  • newPipe Object The pipe to be inserted.
appendPipe

添加一个新的 pipe 到 pipeline 尾部。
该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。

meta description
定义于 cocos2d/core/load-pipeline/pipeline.js:216
参数列表
  • pipe Object The pipe to be appended
flowIn

让新的 item 流入 pipeline 中。
这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象, 如果它是一个对象的话,他必须要包含 ‘id’ 属性。
你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。
也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。
该对象可以包含任何附加属性。

meta description
定义于 cocos2d/core/load-pipeline/pipeline.js:240
参数列表
示例
pipeline.flowIn([
     'res/Background.png',
     {
         id: 'res/scene.json',
         type: 'scene',
         name: 'scene',
         skips: ['Downloader']
     }
 ]);
copyItemStates

从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。
当一个源 item 生成了一系列新的 items 时很有用,
你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,
但是你可能希望他们源 item 已经通过并跳过所有 pipes,
这个时候就可以使用这个 API。

meta description
定义于 cocos2d/core/load-pipeline/pipeline.js:325
参数列表
  • srcItem Object The source item
  • dstItems Array | Object A single destination item or an array of destination items
getItem

根据 id 获取一个 item

meta description
返回 Object
定义于 cocos2d/core/load-pipeline/pipeline.js:354
参数列表
  • id Object The id of the item
removeItem

移除指定的已完成 item。 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。 cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 cc.loader.release

meta description
返回 Boolean
定义于 cocos2d/core/load-pipeline/pipeline.js:374
参数列表
  • id Object The id of the item
clear

清空当前 pipeline,该函数将清理 items。

meta description
定义于 cocos2d/core/load-pipeline/pipeline.js:394

条与 "" 相匹配的结果

    没有与 "" 匹配的结果