zoukankan      html  css  js  c++  java
  • 【cocos2d-js官方文档】十、log

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

    1.  
      cc.log 不变
    2.  
      cc.warn 新增
    3.  
      cc.error 新增
    4.  
      cc.assert <-- cc.Assert

    此次改造有以下几点原因:

    • 添加原来没有的api:cc.warn、cc.error。

    • 修改cc.Assert名称,使其符合开发规范。

    新的api的使用范例:

    1.  
      cc.log("this is a log");
    2.  
      cc.log("this is a log for %s", "Cocos2d-html5");
    3.  
       
    4.  
      cc.warn("this is a waring");
    5.  
      cc.warn("this is a waring for %s", "Cocos2d-html5");
    6.  
       
    7.  
      cc.error("this is an error");
    8.  
      cc.error("this is an error for %s", "Cocos2d-html5");
    9.  
       
    10.  
      cc.assert(false, "this is an assert");
    11.  
      cc.assert(false, "this is an assert for %s", "Cocos2d-html5");

    然后今后会定义出msgCode.js

    1.  
      cc.msgCode = {
    2.  
      log1 : "this is a log",
    3.  
      log2 : "this is a log for %s",
    4.  
      warn1 : "this is a waring",
    5.  
      warn2 : "this is a waring for %s",
    6.  
      error1 : "this is an error",
    7.  
      error2 : "this is an error for %s",
    8.  
      assert1 : "this is an assert",
    9.  
      assert2 : "this is an assert for %s",
    10.  
      throw1 : "this is an throw",
    11.  
      throw2 : "this is an throw for %s", "Cocos2d-html5"
    12.  
      }

    这样一来可以让消息字符串等到最大程度的复用并且利于管理。

    转载:https://blog.csdn.net/qinning199/article/details/40588165

  • 相关阅读:
    正则基础之——贪婪与非贪婪模式
    HTML、css2--IE标签整理
    jQuery技术内幕预览版.pdf3
    jQuery技术内幕预览版.pdf2
    HTML5 Canvas核心技术—图形、动画与游戏开发.pdf1
    jQuery技术内幕预览版.pdf1
    白帽子讲Web安全1.pdf
    js的 new image()用法[转]
    css权威指南(下)
    css权威指南(上)
  • 原文地址:https://www.cnblogs.com/wodehao0808/p/11929590.html
Copyright © 2011-2022 走看看