Skip to content

Commit 39faf46

Browse files
author
linshun
committed
fixed #1503: fixed debug setting
1 parent b21a4c5 commit 39faf46

File tree

5 files changed

+59
-30
lines changed

5 files changed

+59
-30
lines changed

Demo/HelloDomMenu/main.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var cocos2dApp = cc.Application.extend({
3030
this._super();
3131
this.startScene = scene;
3232
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG'];
33+
cc.initDebugSetting();
3334
cc.setup(this.config['tag']);
3435
cc.AudioEngine.getInstance().init("mp3,ogg");
3536
cc.Loader.getInstance().onloading = function () {

Demo/NativeClientDemo/main.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var cocos2dApp = cc.Application.extend({
3030
this._super();
3131
this.startScene = scene;
3232
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG'];
33+
cc.initDebugSetting();
3334
cc.setup(this.config['tag']);
3435
cc.AudioEngine.getInstance().init("mp3,ogg");
3536
cc.Loader.getInstance().onloading = function () {

HelloHTML5World/main.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var cocos2dApp = cc.Application.extend({
3030
this._super();
3131
this.startScene = scene;
3232
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG'];
33+
cc.initDebugSetting();
3334
cc.setup(this.config['tag']);
3435
cc.AudioEngine.getInstance().init("mp3,ogg");
3536
cc.Loader.getInstance().onloading = function () {

cocos2d/platform/CCCommon.js

+55-30
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ cc.clone = function (obj) {
5252
* @param {object} jsobj subclass
5353
* @param {object} klass superclass
5454
*/
55-
cc.associateWithNative = function( jsobj, superclass ) {
55+
cc.associateWithNative = function (jsobj, superclass) {
5656
};
5757

5858
/**
@@ -135,40 +135,65 @@ cc.MessageBox = function (message) {
135135
console.log(message);
136136
};
137137

138-
// cocos2d debug
139-
if (cc.COCOS2D_DEBUG == 0) {
140-
cc.log = function () {
141-
};
142-
cc.logINFO = function () {
143-
};
144-
cc.logERROR = function () {
145-
};
146-
}
147-
else if (cc.COCOS2D_DEBUG == 1) {
148-
cc.logINFO = cc.log;
149-
cc.logERROR = function () {
150-
};
138+
/**
139+
* Output Assert message.
140+
* @function
141+
* @param {Boolean} cond If cond is false, assert.
142+
* @param {String} message
143+
*/
144+
cc.Assert = function (cond, message) {
145+
if ((typeof console.assert) == "function") {
146+
console.assert(cond, message);
147+
} else {
148+
if (!cond) {
149+
if (message) {
150+
alert(message);
151+
}
152+
}
153+
}
151154
}
152-
else if (cc.COCOS2D_DEBUG > 1) {
153-
cc.logINFO = cc.log;
154-
cc.logERROR = cc.log;
155-
}// COCOS2D_DEBUG
156-
157-
if (cc.COCOS2D_DEBUG) {
158-
cc.Assert = function (cond, message) {
159-
if ((typeof console.assert) == "function") {
160-
console.assert(cond, message);
161-
} else {
162-
if (!cond) {
163-
if (message) {
164-
alert(message);
155+
156+
/**
157+
* Update Debug setting.
158+
* @function
159+
*/
160+
cc.initDebugSetting = function () {
161+
// cocos2d debug
162+
if (cc.COCOS2D_DEBUG == 0) {
163+
cc.log = function () {
164+
};
165+
cc.logINFO = function () {
166+
};
167+
cc.logERROR = function () {
168+
};
169+
}
170+
else if (cc.COCOS2D_DEBUG == 1) {
171+
cc.logINFO = cc.log;
172+
cc.logERROR = function () {
173+
};
174+
}
175+
else if (cc.COCOS2D_DEBUG > 1) {
176+
cc.logINFO = cc.log;
177+
cc.logERROR = cc.log;
178+
}// COCOS2D_DEBUG
179+
180+
if (cc.COCOS2D_DEBUG) {
181+
cc.Assert = function (cond, message) {
182+
if ((typeof console.assert) == "function") {
183+
console.assert(cond, message);
184+
} else {
185+
if (!cond) {
186+
if (message) {
187+
alert(message);
188+
}
165189
}
166190
}
167191
}
192+
} else {
193+
cc.Assert = function () {
194+
};
168195
}
169-
} else {
170-
cc.Assert = function () {
171-
};
196+
172197
}
173198

174199
// Enum the language type supportted now

template/main.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var cocos2dApp = cc.Application.extend({
3030
this._super();
3131
this.startScene = scene;
3232
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG'];
33+
cc.initDebugSetting();
3334
cc.setup(this.config['tag']);
3435
cc.AudioEngine.getInstance().init("mp3,ogg");
3536
cc.Loader.getInstance().onloading = function () {

0 commit comments

Comments
 (0)