Task 类型

模块: cc.AssetManager

任务用于在管线中运行以达成某种效果

索引

属性(properties)
方法

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
参数列表
  • 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

设置任务的参数

meta description
定义于 cocos2d/core/asset-manager/task.js:182
参数列表
  • 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
示例
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
参数列表
  • event string The event name
  • param1 Any Parameter 1
  • param2 Any Parameter 2
  • param3 Any Parameter 3
  • param4 Any 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
参数列表
  • 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

条与 "" 相匹配的结果

    没有与 "" 匹配的结果