mirror of https://github.com/axmolengine/axmol.git
Merge pull request #14180 from pandamicro/v3
Fix issue for web engine upgrade
This commit is contained in:
commit
c365fc5883
|
@ -757,7 +757,7 @@ bool ScriptingCore::runScript(const char *path, JS::HandleObject global, JSConte
|
||||||
JSAutoCompartment ac(cx, global);
|
JSAutoCompartment ac(cx, global);
|
||||||
evaluatedOK = JS_ExecuteScript(cx, global, script, &rval);
|
evaluatedOK = JS_ExecuteScript(cx, global, script, &rval);
|
||||||
if (false == evaluatedOK) {
|
if (false == evaluatedOK) {
|
||||||
cocos2d::log("(evaluatedOK == JS_FALSE)");
|
cocos2d::log("Evaluating %s failed (evaluatedOK == JS_FALSE)", path);
|
||||||
JS_ReportPendingException(cx);
|
JS_ReportPendingException(cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1054,6 +1054,15 @@ var _initSys = function () {
|
||||||
*/
|
*/
|
||||||
sys.LANGUAGE_POLISH = "pl";
|
sys.LANGUAGE_POLISH = "pl";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unknown language code
|
||||||
|
* @memberof cc.sys
|
||||||
|
* @name LANGUAGE_UNKNOWN
|
||||||
|
* @constant
|
||||||
|
* @type {Number}
|
||||||
|
*/
|
||||||
|
sys.LANGUAGE_UNKNOWN = "unkonwn";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @memberof cc.sys
|
* @memberof cc.sys
|
||||||
* @name OS_IOS
|
* @name OS_IOS
|
||||||
|
@ -1575,11 +1584,12 @@ cc.game = /** @lends cc.game# */{
|
||||||
jsList: "jsList"
|
jsList: "jsList"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// states
|
||||||
|
_paused: false,//whether the game is paused
|
||||||
_prepareCalled: false,//whether the prepare function has been called
|
_prepareCalled: false,//whether the prepare function has been called
|
||||||
_prepared: false,//whether the engine has prepared
|
_prepared: false,//whether the engine has prepared
|
||||||
_paused: true,//whether the game is paused
|
|
||||||
_intervalId: null,//interval target of main
|
_intervalId: null,//interval target of main
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config of game
|
* Config of game
|
||||||
|
@ -1599,6 +1609,9 @@ cc.game = /** @lends cc.game# */{
|
||||||
*/
|
*/
|
||||||
onStop: null,
|
onStop: null,
|
||||||
|
|
||||||
|
//@Public Methods
|
||||||
|
|
||||||
|
// @Game play control
|
||||||
/**
|
/**
|
||||||
* Set frameRate of game.
|
* Set frameRate of game.
|
||||||
* @param frameRate
|
* @param frameRate
|
||||||
|
@ -1620,6 +1633,7 @@ cc.game = /** @lends cc.game# */{
|
||||||
* Pause the game.
|
* Pause the game.
|
||||||
*/
|
*/
|
||||||
pause: function () {
|
pause: function () {
|
||||||
|
this._paused = true;
|
||||||
cc.director.pause();
|
cc.director.pause();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1627,9 +1641,17 @@ cc.game = /** @lends cc.game# */{
|
||||||
* Resume the game from pause.
|
* Resume the game from pause.
|
||||||
*/
|
*/
|
||||||
resume: function () {
|
resume: function () {
|
||||||
|
this._paused = false;
|
||||||
cc.director.resume();
|
cc.director.resume();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the game is paused.
|
||||||
|
*/
|
||||||
|
isPaused: function () {
|
||||||
|
return this._paused;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restart game.
|
* Restart game.
|
||||||
*/
|
*/
|
||||||
|
@ -1637,6 +1659,7 @@ cc.game = /** @lends cc.game# */{
|
||||||
__restartVM();
|
__restartVM();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// @Game loading
|
||||||
/**
|
/**
|
||||||
* Prepare game.
|
* Prepare game.
|
||||||
* @param cb
|
* @param cb
|
||||||
|
@ -1662,12 +1685,17 @@ cc.game = /** @lends cc.game# */{
|
||||||
this._prepareCalled = true;
|
this._prepareCalled = true;
|
||||||
|
|
||||||
// Load game scripts
|
// Load game scripts
|
||||||
var jsList = config[CONFIG_KEY.jsList] || [];
|
var jsList = config[CONFIG_KEY.jsList];
|
||||||
cc.loader.loadJsWithImg("", jsList, function (err) {
|
if (jsList) {
|
||||||
if (err) throw new Error(err);
|
cc.loader.loadJsWithImg(jsList, function (err) {
|
||||||
self._prepared = true;
|
if (err) throw new Error(err);
|
||||||
|
self._prepared = true;
|
||||||
|
if (cb) cb();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (cb) cb();
|
if (cb) cb();
|
||||||
});
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1679,30 +1707,61 @@ cc.game = /** @lends cc.game# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run game.
|
* Run game with configuration object and onStart function.
|
||||||
|
* @param {Object|Function} [config] Pass configuration object or onStart function
|
||||||
|
* @param {onStart} [onStart] onStart function to be executed after game initialized
|
||||||
*/
|
*/
|
||||||
run: function () {
|
run: function (config, onStart) {
|
||||||
this.prepare(cc.game.onStart.bind(cc.game));
|
if (typeof config === 'function') {
|
||||||
},
|
cc.game.onStart = config;
|
||||||
|
|
||||||
_loadConfig: function () {
|
|
||||||
var self = this, CONFIG_KEY = self.CONFIG_KEY;
|
|
||||||
var _init = function(cfg){
|
|
||||||
cfg[CONFIG_KEY.engineDir] = cfg[CONFIG_KEY.engineDir] || "frameworks/cocos2d-html5";
|
|
||||||
cfg[CONFIG_KEY.debugMode] = cfg[CONFIG_KEY.debugMode] || 0;
|
|
||||||
cfg[CONFIG_KEY.frameRate] = cfg[CONFIG_KEY.frameRate] || 60;
|
|
||||||
cfg[CONFIG_KEY.renderMode] = cfg[CONFIG_KEY.renderMode] || 0;
|
|
||||||
cfg[CONFIG_KEY.showFPS] = cfg[CONFIG_KEY.showFPS] === false ? false : true;
|
|
||||||
return cfg;
|
|
||||||
};
|
|
||||||
try{
|
|
||||||
var txt = jsb.fileUtils.getStringFromFile("project.json");
|
|
||||||
var data = JSON.parse(txt);
|
|
||||||
this.config = _init(data || {});
|
|
||||||
}catch(e){
|
|
||||||
cc.log("Failed to read or parse project.json");
|
|
||||||
this.config = _init({});
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (config) {
|
||||||
|
cc.game.config = config;
|
||||||
|
}
|
||||||
|
if (typeof onStart === 'function') {
|
||||||
|
cc.game.onStart = onStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.prepare(cc.game.onStart && cc.game.onStart.bind(cc.game));
|
||||||
|
},
|
||||||
|
|
||||||
|
//@Private Methods
|
||||||
|
|
||||||
|
_loadConfig: function () {
|
||||||
|
// Load config
|
||||||
|
// Already loaded
|
||||||
|
if (this.config) {
|
||||||
|
this._initConfig(this.config);
|
||||||
|
}
|
||||||
|
// Load from project.json
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
var txt = jsb.fileUtils.getStringFromFile("project.json");
|
||||||
|
var data = JSON.parse(txt);
|
||||||
|
this._initConfig(data || {});
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Failed to read or parse project.json");
|
||||||
|
this._initConfig({});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_initConfig: function (config) {
|
||||||
|
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)
|
||||||
|
config[CONFIG_KEY.debugMode] = 0;
|
||||||
|
config[CONFIG_KEY.frameRate] = config[CONFIG_KEY.frameRate] || 60;
|
||||||
|
if (config[CONFIG_KEY.renderMode] == null)
|
||||||
|
config[CONFIG_KEY.renderMode] = 0;
|
||||||
|
|
||||||
|
this.config = config;
|
||||||
|
|
||||||
cc.director.setDisplayStats(this.config[CONFIG_KEY.showFPS]);
|
cc.director.setDisplayStats(this.config[CONFIG_KEY.showFPS]);
|
||||||
cc.director.setAnimationInterval(1.0/this.config[CONFIG_KEY.frameRate]);
|
cc.director.setAnimationInterval(1.0/this.config[CONFIG_KEY.frameRate]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ var ccbjs = "";
|
||||||
// so the respath will modify to res,
|
// so the respath will modify to res,
|
||||||
if (!cc.sys.isNative)
|
if (!cc.sys.isNative)
|
||||||
{
|
{
|
||||||
|
cc.game._loadConfig();
|
||||||
if (cc.game.config[cc.game.CONFIG_KEY.engineDir] !== "frameworks/cocos2d-html5") {
|
if (cc.game.config[cc.game.CONFIG_KEY.engineDir] !== "frameworks/cocos2d-html5") {
|
||||||
ccbjs = "../../js-tests/resjs/";
|
ccbjs = "../../js-tests/resjs/";
|
||||||
}
|
}
|
||||||
|
|
2
web
2
web
|
@ -1 +1 @@
|
||||||
Subproject commit a9f493ae53d20945d8796660363da4e060a68ee2
|
Subproject commit 6e3797aac97c2dd772fda54996c5677f1acb65bc
|
Loading…
Reference in New Issue