Task Class
Module: cc.AssetManager
Task is used to run in the pipeline for some effect
Index
Properties
idNumberThe id of taskonCompleteFunctionThe callback when task is completedonProgressFunctionThe callback of progressiononErrorFunctionThe callback when something goes wrongsource*The source of taskoutput*The output of taskinput*The input of taskprogress*The progression of taskoptionsObjectCustom optionsisFinishBooleanWhether or not this task is completed
Methods
constructorCreate a new TasksetSet paramters of this taskdispatchDispatch eventrecycleRecycle this for reusecreateCreate a new task from pool
Details
Properties
id
The id of task
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/asset-manager/task.js:47 |
onComplete
The callback when task is completed
| meta | description |
|---|---|
| Type | Function |
| Defined in | cocos2d/core/asset-manager/task.js:61 |
onProgress
The callback of progression
| meta | description |
|---|---|
| Type | Function |
| Defined in | cocos2d/core/asset-manager/task.js:73 |
onError
The callback when something goes wrong
| meta | description |
|---|---|
| Type | Function |
| Defined in | cocos2d/core/asset-manager/task.js:85 |
source
The source of task
| meta | description |
|---|---|
| Type | |
| Defined in | cocos2d/core/asset-manager/task.js:97 |
output
The output of task
| meta | description |
|---|---|
| Type | |
| Defined in | cocos2d/core/asset-manager/task.js:109 |
input
The input of task
| meta | description |
|---|---|
| Type | |
| Defined in | cocos2d/core/asset-manager/task.js:121 |
progress
The progression of task
| meta | description |
|---|---|
| Type | |
| Defined in | cocos2d/core/asset-manager/task.js:133 |
options
Custom options
| meta | description |
|---|---|
| Type | Object |
| Defined in | cocos2d/core/asset-manager/task.js:145 |
isFinish
Whether or not this task is completed
| meta | description |
|---|---|
| Type | Boolean |
| Defined in | cocos2d/core/asset-manager/task.js:282 |
Methods
constructor
Create a new Task
| meta | description |
|---|---|
| Defined in | cocos2d/core/asset-manager/task.js:161 |
Parameters
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
Set paramters of this task
| meta | description |
|---|---|
| Defined in | cocos2d/core/asset-manager/task.js:182 |
Parameters
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
Examples
var task = new Task();
task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)});
dispatch
Dispatch event
| meta | description |
|---|---|
| Defined in | cocos2d/core/asset-manager/task.js:217 |
Parameters
eventstring The event nameparam1Any Parameter 1param2Any Parameter 2param3Any Parameter 3param4Any Parameter 4
Examples
var task = Task.create();
Task.onComplete = (msg) => console.log(msg);
Task.dispatch('complete', 'hello world');
recycle
Recycle this for reuse
| meta | description |
|---|---|
| Defined in | cocos2d/core/asset-manager/task.js:259 |
create
Create a new task from pool
| meta | description |
|---|---|
| Returns | Task |
| Defined in | cocos2d/core/asset-manager/task.js:297 |
Parameters
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