Skip to content

Commit

Permalink
add JsonAsset
Browse files Browse the repository at this point in the history
  • Loading branch information
jareguo committed Apr 28, 2018
1 parent c47f5aa commit 542ef01
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
51 changes: 51 additions & 0 deletions cocos2d/core/assets/CCJsonAsset.js
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions cocos2d/core/assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ require('./CCSpriteAtlas');
require('./CCBitmapFont');
require('./CCLabelAtlas');
require('./CCTextAsset');
require('./CCJsonAsset');

0 comments on commit 542ef01

Please sign in to comment.