Task 类型
模块: cc.AssetManager
任务用于在管线中运行以达成某种效果
索引
属性(properties)
idNumber任务idonCompleteFunction完成回调onProgressFunction进度回调onErrorFunction错误回调source*任务的源output*任务的输出input*任务的输入progress*任务的进度optionsObject自定义参数isFinishBoolean此任务是否已经完成
方法
constructor创建一个任务set设置任务的参数dispatch发布事件recycle回收 task 用于复用create从对象池中创建 task
Details
属性(properties)
id
任务id
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/asset-manager/task.js:47 |
onComplete
完成回调
| meta | description |
|---|---|
| 类型 | Function |
| 定义于 | cocos2d/core/asset-manager/task.js:61 |
onProgress
进度回调
| meta | description |
|---|---|
| 类型 | Function |
| 定义于 | cocos2d/core/asset-manager/task.js:73 |
onError
错误回调
| meta | description |
|---|---|
| 类型 | Function |
| 定义于 | cocos2d/core/asset-manager/task.js:85 |
source
任务的源
| meta | description |
|---|---|
| 类型 | |
| 定义于 | cocos2d/core/asset-manager/task.js:97 |
output
任务的输出
| meta | description |
|---|---|
| 类型 | |
| 定义于 | cocos2d/core/asset-manager/task.js:109 |
input
任务的输入
| meta | description |
|---|---|
| 类型 | |
| 定义于 | cocos2d/core/asset-manager/task.js:121 |
progress
任务的进度
| meta | description |
|---|---|
| 类型 | |
| 定义于 | cocos2d/core/asset-manager/task.js:133 |
options
自定义参数
| meta | description |
|---|---|
| 类型 | Object |
| 定义于 | cocos2d/core/asset-manager/task.js:145 |
isFinish
此任务是否已经完成
| meta | description |
|---|---|
| 类型 | Boolean |
| 定义于 | cocos2d/core/asset-manager/task.js:282 |
方法
constructor
创建一个任务
| meta | description |
|---|---|
| 定义于 | cocos2d/core/asset-manager/task.js:161 |
参数列表
optionsObject Some optional paramtersonCompleteFunction Callback when the task is completed, if the pipeline is synchronous, onComplete is unnecessary.onProgressFunction Continuously callback when the task is runing, if the pipeline is synchronous, onProgress is unnecessary.onErrorFunction Callback when something goes wrong, if the pipeline is synchronous, onError is unnecessary.inputSomething will be handled with pipelineprogressProgress information, you may need to assign it manually when multiple pipeline share one progressoptionsObject Custom parameters
set
设置任务的参数
| meta | description |
|---|---|
| 定义于 | cocos2d/core/asset-manager/task.js:182 |
参数列表
optionsObject Some optional paramtersonCompleteFunction Callback when the task complete, if the pipeline is synchronous, onComplete is unnecessary.onProgressFunction Continuously callback when the task is runing, if the pipeline is synchronous, onProgress is unnecessary.onErrorFunction Callback when something goes wrong, if the pipeline is synchronous, onError is unnecessary.inputSomething will be handled with pipelineprogressProgress information, you may need to assign it manually when multiple pipeline share one progressoptionsObject Custom parameters
示例
var task = new Task();
task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)});
dispatch
发布事件
| meta | description |
|---|---|
| 定义于 | cocos2d/core/asset-manager/task.js:217 |
参数列表
eventstring The event nameparam1Any Parameter 1param2Any Parameter 2param3Any Parameter 3param4Any Parameter 4
示例
var task = Task.create();
Task.onComplete = (msg) => console.log(msg);
Task.dispatch('complete', 'hello world');
recycle
回收 task 用于复用
| meta | description |
|---|---|
| 定义于 | cocos2d/core/asset-manager/task.js:259 |
create
从对象池中创建 task
| meta | description |
|---|---|
| 返回 | Task |
| 定义于 | cocos2d/core/asset-manager/task.js:297 |
参数列表
optionsObject Some optional paramtersonCompleteFunction Callback when the task complete, if the pipeline is synchronous, onComplete is unnecessary.onProgressFunction Continuously callback when the task is runing, if the pipeline is synchronous, onProgress is unnecessary.onErrorFunction Callback when something goes wrong, if the pipeline is synchronous, onError is unnecessary.inputSomething will be handled with pipelineprogressProgress information, you may need to assign it manually when multiple pipeline share one progressoptionsObject Custom parameters