mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
add JsonAsset
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Class for JSON file. When the JSON file is loaded, this object is returned.
|
||||
* The parsed JSON object can be accessed through the `json` attribute in it.<br>
|
||||
* If you want to get the original JSON text, you should modify the extname to `.txt`
|
||||
* so that it is loaded as a `TextAsset` instead of a `JsonAsset`.
|
||||
*
|
||||
* !#zh
|
||||
* JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。<br>
|
||||
* 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。
|
||||
*
|
||||
* @class JsonAsset
|
||||
* @extends Asset
|
||||
*/
|
||||
var JsonAsset = cc.Class({
|
||||
name: 'cc.JsonAsset',
|
||||
extends: cc.Asset,
|
||||
properties: {
|
||||
/**
|
||||
* @property {Object} json - The loaded JSON object.
|
||||
*/
|
||||
json: null,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = cc.JsonAsset = JsonAsset;
|
||||
@@ -38,3 +38,4 @@ require('./CCSpriteAtlas');
|
||||
require('./CCBitmapFont');
|
||||
require('./CCLabelAtlas');
|
||||
require('./CCTextAsset');
|
||||
require('./CCJsonAsset');
|
||||
|
||||
Reference in New Issue
Block a user