【cocos2d-js官方文档】十、log「建议收藏」

【cocos2d-js官方文档】十、log

大家好,又见面了,我是全栈君。

api修改情况。左边为新增,右边为原来的。

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116539.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号