Task Class

Module: cc.AssetManager

Task is used to run in the pipeline for some effect

Index

Properties
  • id Number The id of task
  • onComplete Function The callback when task is completed
  • onProgress Function The callback of progression
  • onError Function The callback when something goes wrong
  • source * The source of task
  • output * The output of task
  • input * The input of task
  • progress * The progression of task
  • options Object Custom options
  • isFinish Boolean Whether or not this task is completed
Methods

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 paramters
    • onComplete 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 pipeline
    • progress Progress information, you may need to assign it manually when multiple pipeline share one progress
    • options 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 paramters
    • onComplete 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 pipeline
    • progress Progress information, you may need to assign it manually when multiple pipeline share one progress
    • options 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 name
  • param1 Any Parameter 1
  • param2 Any Parameter 2
  • param3 Any Parameter 3
  • param4 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 paramters
    • onComplete 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 pipeline
    • progress Progress information, you may need to assign it manually when multiple pipeline share one progress
    • options Object Custom parameters

results matching ""

    No results matching ""