diff --git a/Demo/HelloDomMenu/main.js b/Demo/HelloDomMenu/main.js index af04ca7c3f..1e4a97604f 100644 --- a/Demo/HelloDomMenu/main.js +++ b/Demo/HelloDomMenu/main.js @@ -30,6 +30,7 @@ var cocos2dApp = cc.Application.extend({ this._super(); this.startScene = scene; cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG']; + cc.initDebugSetting(); cc.setup(this.config['tag']); cc.AudioEngine.getInstance().init("mp3,ogg"); cc.Loader.getInstance().onloading = function () { diff --git a/Demo/NativeClientDemo/main.js b/Demo/NativeClientDemo/main.js index af04ca7c3f..1e4a97604f 100644 --- a/Demo/NativeClientDemo/main.js +++ b/Demo/NativeClientDemo/main.js @@ -30,6 +30,7 @@ var cocos2dApp = cc.Application.extend({ this._super(); this.startScene = scene; cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG']; + cc.initDebugSetting(); cc.setup(this.config['tag']); cc.AudioEngine.getInstance().init("mp3,ogg"); cc.Loader.getInstance().onloading = function () { diff --git a/HelloHTML5World/main.js b/HelloHTML5World/main.js index 5896985667..c43c25cb3d 100644 --- a/HelloHTML5World/main.js +++ b/HelloHTML5World/main.js @@ -30,6 +30,7 @@ var cocos2dApp = cc.Application.extend({ this._super(); this.startScene = scene; cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG']; + cc.initDebugSetting(); cc.setup(this.config['tag']); cc.AudioEngine.getInstance().init("mp3,ogg"); cc.Loader.getInstance().onloading = function () { diff --git a/cocos2d/platform/CCCommon.js b/cocos2d/platform/CCCommon.js index d53c8e945e..993d6c7ee5 100644 --- a/cocos2d/platform/CCCommon.js +++ b/cocos2d/platform/CCCommon.js @@ -52,7 +52,7 @@ cc.clone = function (obj) { * @param {object} jsobj subclass * @param {object} klass superclass */ -cc.associateWithNative = function( jsobj, superclass ) { +cc.associateWithNative = function (jsobj, superclass) { }; /** @@ -135,40 +135,49 @@ cc.MessageBox = function (message) { console.log(message); }; -// cocos2d debug -if (cc.COCOS2D_DEBUG == 0) { - cc.log = function () { - }; - cc.logINFO = function () { - }; - cc.logERROR = function () { - }; -} -else if (cc.COCOS2D_DEBUG == 1) { - cc.logINFO = cc.log; - cc.logERROR = function () { - }; -} -else if (cc.COCOS2D_DEBUG > 1) { - cc.logINFO = cc.log; - cc.logERROR = cc.log; -}// COCOS2D_DEBUG - -if (cc.COCOS2D_DEBUG) { - cc.Assert = function (cond, message) { - if ((typeof console.assert) == "function") { - console.assert(cond, message); - } else { - if (!cond) { - if (message) { - alert(message); - } +/** + * Output Assert message. + * @function + * @param {Boolean} cond If cond is false, assert. + * @param {String} message + */ +cc.Assert = function (cond, message) { + if ((typeof console.assert) == "function") { + console.assert(cond, message); + } else { + if (!cond) { + if (message) { + alert(message); } } } -} else { - cc.Assert = function () { - }; +} + +/** + * Update Debug setting. + * @function + */ +cc.initDebugSetting = function () { + // cocos2d debug + if (cc.COCOS2D_DEBUG == 0) { + cc.log = function () { + }; + cc.logINFO = function () { + }; + cc.logERROR = function () { + }; + cc.Assert = function () { + }; + } + else if (cc.COCOS2D_DEBUG == 1) { + cc.logINFO = cc.log; + cc.logERROR = function () { + }; + } + else if (cc.COCOS2D_DEBUG > 1) { + cc.logINFO = cc.log; + cc.logERROR = cc.log; + }// COCOS2D_DEBUG } // Enum the language type supportted now diff --git a/template/main.js b/template/main.js index 70a0abf95d..52742fa37d 100644 --- a/template/main.js +++ b/template/main.js @@ -30,6 +30,7 @@ var cocos2dApp = cc.Application.extend({ this._super(); this.startScene = scene; cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG']; + cc.initDebugSetting(); cc.setup(this.config['tag']); cc.AudioEngine.getInstance().init("mp3,ogg"); cc.Loader.getInstance().onloading = function () {