From 0be3a9b6a9662188e9139694179e7276ed71268f Mon Sep 17 00:00:00 2001 From: 2youyouo2 <501251991@qq.com> Date: Sat, 27 Feb 2016 15:00:56 +0800 Subject: [PATCH] fixed read config --- cocos2d/core/CCGame.js | 18 ++++++++++++------ jsb/jsb-game.js | 14 +++++++++----- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js index d133ad5e43..ed5864936b 100644 --- a/cocos2d/core/CCGame.js +++ b/cocos2d/core/CCGame.js @@ -471,15 +471,21 @@ var game = /** @lends cc.game# */{ modules = config[CONFIG_KEY.modules]; // Configs adjustment - config[CONFIG_KEY.showFPS] = config[CONFIG_KEY.showFPS] || false; - config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || "frameworks/cocos2d-html5"; - if (config[CONFIG_KEY.debugMode] == null) + if (typeof config[CONFIG_KEY.debugMode] !== 'number') { config[CONFIG_KEY.debugMode] = 0; - config[CONFIG_KEY.frameRate] = config[CONFIG_KEY.frameRate] || 60; - if (config[CONFIG_KEY.renderMode] == null) + } + if (typeof config[CONFIG_KEY.frameRate] !== 'number') { + config[CONFIG_KEY.frameRate] = 60; + } + if (typeof config[CONFIG_KEY.renderMode] !== 'number') { config[CONFIG_KEY.renderMode] = 0; - if (config[CONFIG_KEY.registerSystemEvent] == null) + } + if (typeof config[CONFIG_KEY.registerSystemEvent] !== 'boolean') { config[CONFIG_KEY.registerSystemEvent] = true; + } + config[CONFIG_KEY.showFPS] = (CONFIG_KEY.showFPS in config) ? (!!config[CONFIG_KEY.showFPS]) : true; + config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5'; + // Modules adjustment if (modules && modules.indexOf("core") < 0) modules.splice(0, 0, "core"); diff --git a/jsb/jsb-game.js b/jsb/jsb-game.js index 93d9b2a5ac..e79c3dd235 100644 --- a/jsb/jsb-game.js +++ b/jsb/jsb-game.js @@ -217,13 +217,17 @@ cc.js.mixin(cc.game, { var CONFIG_KEY = this.CONFIG_KEY; // Configs adjustment - config[CONFIG_KEY.showFPS] = config[CONFIG_KEY.showFPS] || true; - config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5'; - if (config[CONFIG_KEY.debugMode] == null) + if (typeof config[CONFIG_KEY.debugMode] !== 'number') { config[CONFIG_KEY.debugMode] = 0; - config[CONFIG_KEY.frameRate] = config[CONFIG_KEY.frameRate] || 60; - if (config[CONFIG_KEY.renderMode] == null) + } + if (typeof config[CONFIG_KEY.frameRate] !== 'number') { + config[CONFIG_KEY.frameRate] = 60; + } + if (typeof config[CONFIG_KEY.renderMode] !== 'number') { config[CONFIG_KEY.renderMode] = 0; + } + config[CONFIG_KEY.showFPS] = (CONFIG_KEY.showFPS in config) ? (!!config[CONFIG_KEY.showFPS]) : true; + config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5'; // Scene parser this._sceneInfos = this._sceneInfos.concat(config[CONFIG_KEY.scenes]);