Task
Class
Module: cc.AssetManager
Task is used to run in the pipeline for some effect
Index
Properties
id
Number
The id of taskonComplete
Function
The callback when task is completedonProgress
Function
The callback of progressiononError
Function
The callback when something goes wrongsource
*
The source of taskoutput
*
The output of taskinput
*
The input of taskprogress
*
The progression of taskoptions
Object
Custom optionsisFinish
Boolean
Whether or not this task is completed
Methods
constructor
Create a new Taskset
Set paramters of this taskdispatch
Dispatch eventrecycle
Recycle this for reusecreate
Create 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
options
Object Some optional paramtersonComplete
Function Callback when the task is completed, if the pipeline is synchronous, onComplete is unnecessary.onProgress
Function Continuously callback when the task is runing, if the pipeline is synchronous, onProgress is unnecessary.onError
Function Callback when something goes wrong, if the pipeline is synchronous, onError is unnecessary.input
Something will be handled with pipelineprogress
Progress information, you may need to assign it manually when multiple pipeline share one progressoptions
Object Custom parameters
set
Set paramters of this task
meta | description |
---|---|
Defined in | cocos2d/core/asset-manager/task.js:182 |
Parameters
options
Object Some optional paramtersonComplete
Function Callback when the task complete, if the pipeline is synchronous, onComplete is unnecessary.onProgress
Function Continuously callback when the task is runing, if the pipeline is synchronous, onProgress is unnecessary.onError
Function Callback when something goes wrong, if the pipeline is synchronous, onError is unnecessary.input
Something will be handled with pipelineprogress
Progress information, you may need to assign it manually when multiple pipeline share one progressoptions
Object 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
event
string The event nameparam1
Any Parameter 1param2
Any Parameter 2param3
Any Parameter 3param4
Any 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
options
Object Some optional paramtersonComplete
Function Callback when the task complete, if the pipeline is synchronous, onComplete is unnecessary.onProgress
Function Continuously callback when the task is runing, if the pipeline is synchronous, onProgress is unnecessary.onError
Function Callback when something goes wrong, if the pipeline is synchronous, onError is unnecessary.input
Something will be handled with pipelineprogress
Progress information, you may need to assign it manually when multiple pipeline share one progressoptions
Object Custom parameters