mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 15:42:39 +08:00
Fix JSB issues
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
"expect",
|
||||
"it",
|
||||
"cc",
|
||||
"CC_JSB",
|
||||
"CC_EDITOR",
|
||||
"CC_DEV",
|
||||
"CC_TEST",
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
var spine = require('./spine-exported');
|
||||
if (!CC_JSB) {
|
||||
var spine = require('./spine-exported');
|
||||
}
|
||||
|
||||
/**
|
||||
* @module sp
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
var spine = require('./spine-exported');
|
||||
if (!CC_JSB) {
|
||||
var spine = require('./spine-exported');
|
||||
}
|
||||
|
||||
/**
|
||||
* @module sp
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
var spine = require('./spine-exported');
|
||||
if (!CC_JSB) {
|
||||
var spine = require('./spine-exported');
|
||||
}
|
||||
|
||||
/**
|
||||
* @module sp
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
var spine = require('./spine-exported');
|
||||
if (!CC_JSB) {
|
||||
var spine = require('./spine-exported');
|
||||
}
|
||||
|
||||
/**
|
||||
* @module sp
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
sp = {};
|
||||
|
||||
if (!CC_EDITOR || !Editor.isCoreLevel) {
|
||||
if (!CC_JSB && (!CC_EDITOR || !Editor.isCoreLevel)) {
|
||||
require('./Skeleton');
|
||||
require('./SkeletonCanvasRenderCmd');
|
||||
require('./SkeletonWebGLRenderCmd');
|
||||
|
||||
+8
-4
@@ -66,14 +66,16 @@ function rebundle(bundler) {
|
||||
var dev = uglify(getUglifyOptions(false, {
|
||||
CC_EDITOR: false,
|
||||
CC_DEV: false,
|
||||
CC_TEST: false
|
||||
CC_TEST: false,
|
||||
CC_JSB: false
|
||||
}));
|
||||
|
||||
var min = rename({ suffix: '-min' });
|
||||
min.pipe(uglify(getUglifyOptions(true, {
|
||||
CC_EDITOR: false,
|
||||
CC_DEV: false,
|
||||
CC_TEST: false
|
||||
CC_TEST: false,
|
||||
CC_JSB: false
|
||||
})));
|
||||
|
||||
return bundler.bundle()
|
||||
@@ -107,7 +109,8 @@ function rebundle_test(bundler, suffix) {
|
||||
bundle = bundle.pipe(uglify(getUglifyOptions(false, {
|
||||
CC_EDITOR: TestEditorExtends,
|
||||
CC_DEV: TestEditorExtends || true,
|
||||
CC_TEST: true
|
||||
CC_TEST: true,
|
||||
CC_JSB: false
|
||||
})));
|
||||
if (SourceMap) {
|
||||
bundle = bundle.pipe(sourcemaps.write('./', {sourceRoot: './', addComment: true}));
|
||||
@@ -179,7 +182,8 @@ function rebundle_jsb(bundler, minify, suffix) {
|
||||
bundle = bundle.pipe(uglify(getUglifyOptions(minify, {
|
||||
CC_EDITOR: false,
|
||||
CC_DEV: false,
|
||||
CC_TEST: false
|
||||
CC_TEST: false,
|
||||
CC_JSB: true
|
||||
})));
|
||||
if (SourceMap) {
|
||||
bundle = bundle.pipe(sourcemaps.write('./', {sourceRoot: './', addComment: true}));
|
||||
|
||||
@@ -23,6 +23,7 @@ paths = {
|
||||
'../../cocos2d/core/platform/CCLoader',
|
||||
'../../cocos2d/core/platform/CCLoaders',
|
||||
'../../cocos2d/core/event/event',
|
||||
'../../extensions/spine/spine-exported',
|
||||
],
|
||||
|
||||
test: {
|
||||
|
||||
@@ -33,7 +33,8 @@ eval(
|
||||
'if(typeof CC_EDITOR=="undefined")' +
|
||||
'CC_EDITOR=typeof Editor=="object"&&typeof process=="object"&&"electron" in process.versions;' +
|
||||
'if(typeof CC_DEV=="undefined")' +
|
||||
'CC_DEV=CC_EDITOR||CC_TEST;'
|
||||
'CC_DEV=CC_EDITOR||CC_TEST;' +
|
||||
'CC_JSB=false;'
|
||||
);
|
||||
|
||||
// PREDEFINE
|
||||
|
||||
+3
-3
@@ -50,9 +50,9 @@ if (_engineNumberVersion) {
|
||||
}
|
||||
}
|
||||
|
||||
var originLog = console.log;
|
||||
var log = console.log = function () {
|
||||
originLog.call(console, cc.formatStr.apply(null, arguments));
|
||||
// var originLog = console.log;
|
||||
var log = function () {
|
||||
console.log.call(console, cc.formatStr.apply(null, arguments));
|
||||
};
|
||||
|
||||
cc.log = log;
|
||||
|
||||
+2
-2
@@ -299,14 +299,14 @@ cc.Director.EVENT_COMPONENT_UPDATE = 'director_component_update';
|
||||
cc.Director.EVENT_COMPONENT_LATE_UPDATE = 'director_component_late_update';
|
||||
|
||||
cc.eventManager.addCustomListener(cc.Director.EVENT_BEFORE_UPDATE, function () {
|
||||
var dt = 1 / cc.game.config[cc.game.CONFIG_KEY.frameRate];
|
||||
var dt = 1 / 60;
|
||||
// Call start for new added components
|
||||
cc.director.emit(cc.Director.EVENT_BEFORE_UPDATE);
|
||||
// Update for components
|
||||
cc.director.emit(cc.Director.EVENT_COMPONENT_UPDATE, dt);
|
||||
});
|
||||
cc.eventManager.addCustomListener(cc.Director.EVENT_AFTER_UPDATE, function () {
|
||||
var dt = 1 / cc.game.config[cc.game.CONFIG_KEY.frameRate];
|
||||
var dt = 1 / 60;
|
||||
// Late update for components
|
||||
cc.director.emit(cc.Director.EVENT_COMPONENT_LATE_UPDATE, dt);
|
||||
// User can use this event to do things after update
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ cc.EditBox.InputFlag = cc.Enum({
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
cc.KeyboardReturnType = cc.Enum({
|
||||
cc.EditBox.KeyboardReturnType = cc.Enum({
|
||||
DEFAULT: 0,
|
||||
DONE: 1,
|
||||
SEND: 2,
|
||||
|
||||
+1
-1
@@ -260,7 +260,7 @@ window._ccsg = {
|
||||
Sprite: cc.Sprite,
|
||||
ParticleSystem: cc.ParticleSystem,
|
||||
Label: cc.Label,
|
||||
|
||||
EditBox: cc.EditBox
|
||||
};
|
||||
|
||||
// rename cc.Class to cc._Class
|
||||
|
||||
+71
-31
@@ -26,7 +26,47 @@
|
||||
|
||||
// cc.Scale9Sprite
|
||||
|
||||
cc.Scale9Sprite.prototype._lazyInit = function () {
|
||||
cc.Scale9Sprite.state = {NORMAL: 0, GRAY: 1};
|
||||
|
||||
/**
|
||||
* Enum for sprite type
|
||||
* @enum SpriteType
|
||||
*/
|
||||
cc.Scale9Sprite.RenderingType = cc.Enum({
|
||||
/**
|
||||
* @property {Number} SIMPLE
|
||||
*/
|
||||
SIMPLE: 0,
|
||||
/**
|
||||
* @property {Number} SLICED
|
||||
*/
|
||||
SLICED: 1,
|
||||
/*
|
||||
* @property {Number} TILED
|
||||
*/
|
||||
TILED: 2,
|
||||
/*
|
||||
* @property {Number} FILLED
|
||||
*/
|
||||
FILLED: 3
|
||||
});
|
||||
|
||||
cc.Scale9Sprite.FillType = cc.Enum({
|
||||
Horizontal: 0,
|
||||
Vertical: 1,
|
||||
//todo implement this
|
||||
RADIAL:2,
|
||||
});
|
||||
|
||||
var s9sPrototype = cc.Scale9Sprite.prototype;
|
||||
|
||||
s9sPrototype.setFillType = function () {};
|
||||
s9sPrototype.setFillCenter = function () {};
|
||||
s9sPrototype.setFillStart = function () {};
|
||||
s9sPrototype.setFillRange = function () {};
|
||||
s9sPrototype.enableTrimmedContentSize = function () {};
|
||||
|
||||
s9sPrototype._lazyInit = function () {
|
||||
if (this._onceInit) return;
|
||||
this._onceInit = true;
|
||||
this._insets = {left: 0, right: 0, top: 0, bottom: 0};
|
||||
@@ -36,11 +76,11 @@ cc.Scale9Sprite.prototype._lazyInit = function () {
|
||||
this._sizeAfterTrimmed = new cc.Size(0, 0);
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._applyInsetsContentAnchor = function () {
|
||||
s9sPrototype._applyInsetsContentAnchor = function () {
|
||||
var renderingType = this._renderingType || (this.getRenderingType && this.getRenderingType());
|
||||
var trimScaleX = 1;
|
||||
var trimScaleY = 1;
|
||||
if (renderingType === cc.SpriteType.SIMPLE) {
|
||||
if (renderingType === cc.Scale9Sprite.RenderingType.SIMPLE) {
|
||||
trimScaleX = this._contentSizeTrimmed.width / this._sizeAfterTrimmed.width;
|
||||
trimScaleY = this._contentSizeTrimmed.height / this._sizeAfterTrimmed.height;
|
||||
}
|
||||
@@ -68,8 +108,8 @@ cc.Scale9Sprite.prototype._applyInsetsContentAnchor = function () {
|
||||
this.setCapInsets(capinsets);
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._setBlendFunc = cc.Scale9Sprite.prototype.setBlendFunc;
|
||||
cc.Scale9Sprite.prototype.setBlendFunc = function (blendFunc, dst) {
|
||||
s9sPrototype._setBlendFunc = s9sPrototype.setBlendFunc;
|
||||
s9sPrototype.setBlendFunc = function (blendFunc, dst) {
|
||||
if (void 0 !== dst) {
|
||||
blendFunc = {
|
||||
src: blendFunc,
|
||||
@@ -78,13 +118,13 @@ cc.Scale9Sprite.prototype.setBlendFunc = function (blendFunc, dst) {
|
||||
}
|
||||
this._setBlendFunc(blendFunc);
|
||||
};
|
||||
cc.Scale9Sprite.prototype._getContentSize = cc.Scale9Sprite.prototype.getContentSize;
|
||||
cc.Scale9Sprite.prototype.getContentSize = function () {
|
||||
s9sPrototype._getContentSize = s9sPrototype.getContentSize;
|
||||
s9sPrototype.getContentSize = function () {
|
||||
return new cc.Size(this._contentSizeTrimmed);
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._setContentSize = cc.Scale9Sprite.prototype.setContentSize;
|
||||
cc.Scale9Sprite.prototype.setContentSize = function (size, height) {
|
||||
s9sPrototype._setContentSize = s9sPrototype.setContentSize;
|
||||
s9sPrototype.setContentSize = function (size, height) {
|
||||
this._lazyInit();
|
||||
if (void 0 !== height) {
|
||||
size = new cc.Size(size, height);
|
||||
@@ -93,13 +133,13 @@ cc.Scale9Sprite.prototype.setContentSize = function (size, height) {
|
||||
this._applyInsetsContentAnchor();
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._getAnchorPoint = cc.Scale9Sprite.prototype.getAnchorPoint;
|
||||
cc.Scale9Sprite.prototype.getAnchorPoint = function () {
|
||||
s9sPrototype._getAnchorPoint = s9sPrototype.getAnchorPoint;
|
||||
s9sPrototype.getAnchorPoint = function () {
|
||||
return new cc.Vec2(this._anchorPointTrimmed);
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._setAnchorPoint = cc.Scale9Sprite.prototype.setAnchorPoint;
|
||||
cc.Scale9Sprite.prototype.setAnchorPoint = function (anchorPoint, y) {
|
||||
s9sPrototype._setAnchorPoint = s9sPrototype.setAnchorPoint;
|
||||
s9sPrototype.setAnchorPoint = function (anchorPoint, y) {
|
||||
this._lazyInit();
|
||||
if (void 0 !== y) {
|
||||
anchorPoint = new cc.Vec2(anchorPoint, y);
|
||||
@@ -108,53 +148,53 @@ cc.Scale9Sprite.prototype.setAnchorPoint = function (anchorPoint, y) {
|
||||
this._applyInsetsContentAnchor();
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._getInsetLeft = cc.Scale9Sprite.prototype.getInsetLeft;
|
||||
cc.Scale9Sprite.prototype._getInsetRight = cc.Scale9Sprite.prototype.getInsetRight;
|
||||
cc.Scale9Sprite.prototype._getInsetBottom = cc.Scale9Sprite.prototype.getInsetBottom;
|
||||
cc.Scale9Sprite.prototype._getInsetTop = cc.Scale9Sprite.prototype.getInsetTop;
|
||||
cc.Scale9Sprite.prototype.getInsetLeft = function () {
|
||||
s9sPrototype._getInsetLeft = s9sPrototype.getInsetLeft;
|
||||
s9sPrototype._getInsetRight = s9sPrototype.getInsetRight;
|
||||
s9sPrototype._getInsetBottom = s9sPrototype.getInsetBottom;
|
||||
s9sPrototype._getInsetTop = s9sPrototype.getInsetTop;
|
||||
s9sPrototype.getInsetLeft = function () {
|
||||
return this._insets.left;
|
||||
};
|
||||
cc.Scale9Sprite.prototype.getInsetRight = function () {
|
||||
s9sPrototype.getInsetRight = function () {
|
||||
return this._insets.right;
|
||||
};
|
||||
cc.Scale9Sprite.prototype.getInsetBottom = function () {
|
||||
s9sPrototype.getInsetBottom = function () {
|
||||
return this._insets.bottom;
|
||||
};
|
||||
cc.Scale9Sprite.prototype.getInsetTop = function () {
|
||||
s9sPrototype.getInsetTop = function () {
|
||||
return this._insets.top;
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._setInsetLeft = cc.Scale9Sprite.prototype.setInsetLeft;
|
||||
cc.Scale9Sprite.prototype.setInsetLeft = function (insetLeft) {
|
||||
s9sPrototype._setInsetLeft = s9sPrototype.setInsetLeft;
|
||||
s9sPrototype.setInsetLeft = function (insetLeft) {
|
||||
this._lazyInit();
|
||||
this._insets.left = insetLeft;
|
||||
this._applyInsetsContentAnchor();
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._setInsetRight = cc.Scale9Sprite.prototype.setInsetRight;
|
||||
cc.Scale9Sprite.prototype.setInsetRight = function (insetRight) {
|
||||
s9sPrototype._setInsetRight = s9sPrototype.setInsetRight;
|
||||
s9sPrototype.setInsetRight = function (insetRight) {
|
||||
this._lazyInit();
|
||||
this._insets.right = insetRight;
|
||||
this._applyInsetsContentAnchor();
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._setInsetTop = cc.Scale9Sprite.prototype.setInsetTop;
|
||||
cc.Scale9Sprite.prototype.setInsetTop = function (insetTop) {
|
||||
s9sPrototype._setInsetTop = s9sPrototype.setInsetTop;
|
||||
s9sPrototype.setInsetTop = function (insetTop) {
|
||||
this._lazyInit();
|
||||
this._insets.top = insetTop;
|
||||
this._applyInsetsContentAnchor();
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._setInsetBottom = cc.Scale9Sprite.prototype.setInsetBottom;
|
||||
cc.Scale9Sprite.prototype.setInsetBottom = function (insetBottom) {
|
||||
s9sPrototype._setInsetBottom = s9sPrototype.setInsetBottom;
|
||||
s9sPrototype.setInsetBottom = function (insetBottom) {
|
||||
this._lazyInit();
|
||||
this._insets.bottom = insetBottom;
|
||||
this._applyInsetsContentAnchor();
|
||||
};
|
||||
|
||||
cc.Scale9Sprite.prototype._setSpriteFrame = cc.Scale9Sprite.prototype.setSpriteFrame;
|
||||
cc.Scale9Sprite.prototype.setSpriteFrame = function (spriteFrame) {
|
||||
s9sPrototype._setSpriteFrame = s9sPrototype.setSpriteFrame;
|
||||
s9sPrototype.setSpriteFrame = function (spriteFrame) {
|
||||
this._lazyInit();
|
||||
var originalSize = spriteFrame.getOriginalSize();
|
||||
var spriteRect = spriteFrame.getRect();
|
||||
|
||||
@@ -32,7 +32,7 @@ cc.Scale9Sprite.prototype.setRenderingType = function (type) {
|
||||
this.setScale9Enabled(true);
|
||||
}
|
||||
|
||||
if (type === cc.SpriteType.SIMPLE) {
|
||||
if (type === cc.Scale9Sprite.RenderingType.SIMPLE) {
|
||||
// Should modify based on trim size
|
||||
this.setInsetLeft(0);
|
||||
this.setInsetTop(0);
|
||||
|
||||
Reference in New Issue
Block a user