From 0d8651239352ab756518e18a92467b86319a9898 Mon Sep 17 00:00:00 2001 From: 2youyouo2 <501251991@qq.com> Date: Fri, 15 Apr 2016 10:21:20 +0800 Subject: [PATCH 1/2] fixed jsb on 3.9 --- jsb/jsb-game.js | 4 ++++ jsb/versions/jsb-polyfill-v3.9.js | 30 ++++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/jsb/jsb-game.js b/jsb/jsb-game.js index 74d782c544..b9469c2b3d 100644 --- a/jsb/jsb-game.js +++ b/jsb/jsb-game.js @@ -37,6 +37,10 @@ cc.js.mixin(cc.game, { _persistRootNodes: {}, _ignoreRemovePersistNode: null, + RENDER_TYPE_CANVAS: 0, + RENDER_TYPE_WEBGL: 1, + RENDER_TYPE_OPENGL: 2, + CONFIG_KEY: { width: 'width', height: 'height', diff --git a/jsb/versions/jsb-polyfill-v3.9.js b/jsb/versions/jsb-polyfill-v3.9.js index 3eaa4f4632..07fcb4aebd 100644 --- a/jsb/versions/jsb-polyfill-v3.9.js +++ b/jsb/versions/jsb-polyfill-v3.9.js @@ -25,19 +25,21 @@ 'use strict'; -cc.Scale9Sprite.prototype.setRenderingType = function (type) { - if (this._renderingType === type) return; - this._renderingType = type; +if (cc.Scale9Sprite !== cc.Scale9SpriteV2) { + cc.Scale9Sprite.prototype.setRenderingType = function (type) { + if (this._renderingType === type) return; + this._renderingType = type; - if (!this.isScale9Enabled()){ - this.setScale9Enabled(true); - } + if (!this.isScale9Enabled()){ + this.setScale9Enabled(true); + } - if (type === cc.Scale9Sprite.RenderingType.SIMPLE) { - // Should modify based on trim size - this.setInsetLeft(0); - this.setInsetTop(0); - this.setInsetBottom(0); - this.setInsetRight(0); - } -}; \ No newline at end of file + if (type === cc.Scale9Sprite.RenderingType.SIMPLE) { + // Should modify based on trim size + this.setInsetLeft(0); + this.setInsetTop(0); + this.setInsetBottom(0); + this.setInsetRight(0); + } + }; +} From ebc999da138352831354ec5d96229d1dd49ddce8 Mon Sep 17 00:00:00 2001 From: 2youyouo2 <501251991@qq.com> Date: Mon, 18 Apr 2016 10:11:17 +0800 Subject: [PATCH 2/2] load version polyfills first --- jsb/index.js | 57 ++++++++++++++++--------------- jsb/versions/jsb-polyfill-v3.9.js | 30 ++++++++-------- 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/jsb/index.js b/jsb/index.js index 78a46bf954..27348fa617 100644 --- a/jsb/index.js +++ b/jsb/index.js @@ -25,6 +25,35 @@ 'use strict'; +// Check version +var _engineNumberVersion = (function () { + var result = /Cocos2d\-JS\sv([\d]+)\.([\d]+)/.exec(cc.ENGINE_VERSION); + if (result && result[1]) { + return { + major: parseInt(result[1]), + minor: parseInt(result[2]) + }; + } + else { + return null; + } +})(); + +// Version polyfills +if (_engineNumberVersion) { + if (_engineNumberVersion.major === 3) { + if (_engineNumberVersion.minor < 6) { + require('./versions/jsb-polyfill-v3.5'); + } + if (_engineNumberVersion.minor < 9) { + require('./versions/jsb-polyfill-v3.8'); + } + if (_engineNumberVersion.minor < 10) { + require('./versions/jsb-polyfill-v3.9'); + } + } +} + // cc.initEngine cc.initEngine = function (config, cb) { require('script/jsb.js'); @@ -73,31 +102,3 @@ require('./jsb-event'); require('./jsb-action'); require('./jsb-etc'); -// Check version -var _engineNumberVersion = (function () { - var result = /Cocos2d\-JS\sv([\d]+)\.([\d]+)/.exec(cc.ENGINE_VERSION); - if (result && result[1]) { - return { - major: parseInt(result[1]), - minor: parseInt(result[2]) - }; - } - else { - return null; - } -})(); - -// Version polyfills -if (_engineNumberVersion) { - if (_engineNumberVersion.major === 3) { - if (_engineNumberVersion.minor < 6) { - require('./versions/jsb-polyfill-v3.5'); - } - if (_engineNumberVersion.minor < 9) { - require('./versions/jsb-polyfill-v3.8'); - } - if (_engineNumberVersion.minor < 10) { - require('./versions/jsb-polyfill-v3.9'); - } - } -} diff --git a/jsb/versions/jsb-polyfill-v3.9.js b/jsb/versions/jsb-polyfill-v3.9.js index 07fcb4aebd..f14a6820b1 100644 --- a/jsb/versions/jsb-polyfill-v3.9.js +++ b/jsb/versions/jsb-polyfill-v3.9.js @@ -25,21 +25,19 @@ 'use strict'; -if (cc.Scale9Sprite !== cc.Scale9SpriteV2) { - cc.Scale9Sprite.prototype.setRenderingType = function (type) { - if (this._renderingType === type) return; - this._renderingType = type; +cc.Scale9Sprite.prototype.setRenderingType = function (type) { + if (this._renderingType === type) return; + this._renderingType = type; - if (!this.isScale9Enabled()){ - this.setScale9Enabled(true); - } + if (!this.isScale9Enabled()){ + this.setScale9Enabled(true); + } - if (type === cc.Scale9Sprite.RenderingType.SIMPLE) { - // Should modify based on trim size - this.setInsetLeft(0); - this.setInsetTop(0); - this.setInsetBottom(0); - this.setInsetRight(0); - } - }; -} + if (type === cc.Scale9Sprite.RenderingType.SIMPLE) { + // Should modify based on trim size + this.setInsetLeft(0); + this.setInsetTop(0); + this.setInsetBottom(0); + this.setInsetRight(0); + } +};