Parser
Class
Module: cc.AssetManager
Parse the downloaded file, it's a singleton, all member can be accessed with cc.assetManager.parser
Index
Methods
register
Register custom handler if you want to change default behavior or extend parser to parse other format fileparse
Use corresponding handler to parse file
Details
Methods
register
Register custom handler if you want to change default behavior or extend parser to parse other format file
meta | description |
---|---|
Defined in | cocos2d/core/asset-manager/parser.js:443 |
Parameters
type
string | Object Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler}handler
Function The corresponding handler
Examples
parser.register('.tga', (file, options, onComplete) => onComplete(null, null));
parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)});
parse
Use corresponding handler to parse file
meta | description |
---|---|
Defined in | cocos2d/core/asset-manager/parser.js:474 |
Parameters
id
string The id of filefile
Any Filetype
string The corresponding type of file, likes '.jpg'.options
Object Some optional paramters will be transferred to the corresponding handler.onComplete
Function callback when finishing downloadingerr
Error The occurred error, null indicetes successcontetnt
The parsed file
Examples
downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => {
parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err));
});