【cocos2d-js官方文档】十、log
2014-10-29 16:28
429 查看
cc.log 不变 cc.warn 新增 cc.error 新增 cc.assert <-- cc.Assert
此次改造有以下几点原因:
添加原来没有的api:cc.warn、cc.error。
修改cc.Assert名称,使其符合开发规范。
新的api的使用范例:
cc.log("this is a log"); cc.log("this is a log for %s", "Cocos2d-html5"); cc.warn("this is a waring"); cc.warn("this is a waring for %s", "Cocos2d-html5"); cc.error("this is an error"); cc.error("this is an error for %s", "Cocos2d-html5"); cc.assert(false, "this is an assert"); cc.assert(false, "this is an assert for %s", "Cocos2d-html5");
然后今后会定义出
msgCode.js
cc.msgCode = { log1 : "this is a log", log2 : "this is a log for %s", warn1 : "this is a waring", warn2 : "this is a waring for %s", error1 : "this is an error", error2 : "this is an error for %s", assert1 : "this is an assert", assert2 : "this is an assert for %s", throw1 : "this is an throw", throw2 : "this is an throw for %s", "Cocos2d-html5" }
这样一来可以让消息字符串等到最大程度的复用并且利于管理。
转载:http://www.douapp.com/post/2454
相关文章推荐
- 【cocos2d-js官方文档】十、log
- 【cocos2d-js官方文档】十、log
- 【cocos2d-js官方文档】三、Bake功能使用说明
- 【cocos2d-js官方文档】八、cc.game
- 【cocos2d-js官方文档】二十一、v3相对于v2版本的api变动
- 【Cocos2d-js官方文档】 九、cc.loader
- 【cocos2d-js官方文档】二十五、Cocos2d-JS v3.0中的单例对象
- 【cocos2d-js官方文档】四、基础数据类型
- 【cocos2d-js官方文档】十七、事件分发机制
- 【cocos2d-js官方文档】二十二、project.json
- 【cocos2d-js官方文档】十八、Cocos2d-js v3.0的对象构造和类继承
- 【cocos2d-js官方文档】五、Cocos2d-JS v3.0的新Action API
- 【cocos2d-js官方文档】十一、cc.path
- 【cocos2d-js官方文档】二十三、如何在IOS平台上使用js直接调用OC方法
- 【cocos2d-js官方文档】一、搭建 Cocos2d-JS 开发环境
- 【cocos2d-js官方文档】七、CCFileUtils
- 【cocos2d-js官方文档】十三、CCSAXParser.js
- 【cocos2d-js官方文档】十四、cc.spriteFrameCache 改造说明
- 【cocos2d-js官方文档】十七、事件分发机制
- 【cocos2d-js官方文档】二十四、如何在android平台上使用js直接调用Java方法