mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
Fix issues for jsb runtime
This commit is contained in:
@@ -37,6 +37,7 @@ cc.Scene = cc.Class({
|
||||
|
||||
ctor: function () {
|
||||
var sgNode = this._sgNode = new _ccsg.Scene();
|
||||
sgNode.retain();
|
||||
sgNode.setAnchorPoint(0.0, 0.0);
|
||||
this._anchorPoint.x = 0.0;
|
||||
this._anchorPoint.y = 0.0;
|
||||
@@ -49,6 +50,8 @@ cc.Scene = cc.Class({
|
||||
var children = this._children;
|
||||
var DontDestroy = cc.Object.Flags.DontDestroy;
|
||||
|
||||
this._sgNode.release();
|
||||
|
||||
for (var i = 0, len = children.length; i < len; ++i) {
|
||||
var child = children[i];
|
||||
if (child.isValid) {
|
||||
|
||||
@@ -145,7 +145,7 @@ var Canvas = cc.Class({
|
||||
if (CC_EDITOR) {
|
||||
cc.engine.on('design-resolution-changed', this._thisOnResized);
|
||||
}
|
||||
else {
|
||||
else if (!cc.sys.isNative) {
|
||||
if (cc.sys.isMobile) {
|
||||
window.addEventListener('resize', this._thisOnResized);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ var Canvas = cc.Class({
|
||||
if (CC_EDITOR) {
|
||||
cc.engine.off('design-resolution-changed', this._thisOnResized);
|
||||
}
|
||||
else {
|
||||
else if (!cc.sys.isNative) {
|
||||
if (cc.sys.isMobile) {
|
||||
window.removeEventListener('resize', this._thisOnResized);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ var ComponentInSG = cc.Class({
|
||||
sgParent.addChild(sgNode);
|
||||
|
||||
// retain immediately
|
||||
// will be released in SceneGraphHelper.removeSgNode
|
||||
sgNode.retain();
|
||||
this._sgNode = sgNode;
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ var SpriteRenderer = cc.Class({
|
||||
},
|
||||
|
||||
_applySprite: function (sgNode, oldSprite) {
|
||||
if (oldSprite) {
|
||||
if (oldSprite && oldSprite.off) {
|
||||
oldSprite.off('load', this._applyCapInset, this);
|
||||
}
|
||||
if (!this._sprite) { return; }
|
||||
|
||||
@@ -414,6 +414,10 @@ var _Deserializer = (function () {
|
||||
else {
|
||||
// instantiate a new object
|
||||
obj = new klass();
|
||||
// Temporary solution
|
||||
if (cc.sys.isNative && klass === cc.SpriteFrame) {
|
||||
obj.retain();
|
||||
}
|
||||
}
|
||||
|
||||
if (obj._deserialize) {
|
||||
|
||||
@@ -180,7 +180,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._skewX = value;
|
||||
this._sgNode.skewX = value;
|
||||
this._sgNode.setSkewX(value);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -195,7 +195,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._skewY = value;
|
||||
this._sgNode._skewY = value;
|
||||
this._sgNode.setSkewY(value);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -210,7 +210,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._localZOrder = value;
|
||||
this._sgNode.zIndex = value;
|
||||
this._sgNode.setLocalZOrder(value);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -227,7 +227,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._rotationX = this._rotationY = value;
|
||||
this._sgNode.rotation = value;
|
||||
this._sgNode.setRotation(value);
|
||||
},
|
||||
tooltip: "The clockwise degrees of rotation relative to the parent"
|
||||
},
|
||||
@@ -243,7 +243,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._rotationX = value;
|
||||
this._sgNode.rotationX = value;
|
||||
this._sgNode.setRotationX(value);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -258,7 +258,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._rotationY = value;
|
||||
this._sgNode.rotationY = value;
|
||||
this._sgNode.setRotationY(value);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -273,7 +273,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._scaleX = value;
|
||||
this._sgNode.scaleX = value;
|
||||
this._sgNode.setScaleX(value);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -288,7 +288,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._scaleY = value;
|
||||
this._sgNode.scaleY = value;
|
||||
this._sgNode.setScaleY(value);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -303,7 +303,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._position.x = value;
|
||||
this._sgNode.x = value;
|
||||
this._sgNode.setPositionX(value);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -318,7 +318,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._position.y = value;
|
||||
this._sgNode.y = value;
|
||||
this._sgNode.setPositionY(value);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -395,7 +395,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
set: function (value) {
|
||||
if (value !== this._contentSize.width) {
|
||||
if (this._sizeProvider) {
|
||||
this._sizeProvider.setContentSize(new cc.Size(value, this._sizeProvider._getHeight()));
|
||||
this._sizeProvider.setContentSize(value, this._sizeProvider._getHeight());
|
||||
}
|
||||
this._contentSize.width = value;
|
||||
this.emit(SIZE_CHANGED);
|
||||
@@ -422,7 +422,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
set: function (value) {
|
||||
if (value !== this._contentSize.height) {
|
||||
if (this._sizeProvider) {
|
||||
this._sizeProvider.setContentSize(new cc.Size(this._sizeProvider._getWidth(), value));
|
||||
this._sizeProvider.setContentSize(this._sizeProvider._getWidth(), value);
|
||||
}
|
||||
this._contentSize.height = value;
|
||||
this.emit(SIZE_CHANGED);
|
||||
@@ -445,7 +445,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._ignoreAnchorPointForPosition = value;
|
||||
this._sgNode.ignoreAnchor = value;
|
||||
this._sgNode.ignoreAnchorPointForPosition(value);
|
||||
this._onAnchorChanged();
|
||||
},
|
||||
},
|
||||
@@ -461,7 +461,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._tag = value;
|
||||
this._sgNode.tag = value;
|
||||
this._sgNode.setTag(value);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -476,7 +476,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
},
|
||||
set: function (value) {
|
||||
this._opacity = value;
|
||||
this._sgNode.opacity = value;
|
||||
this._sgNode.setOpacity(value);
|
||||
this._onColorChanged();
|
||||
},
|
||||
range: [0, 255]
|
||||
@@ -494,7 +494,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
set: function (value) {
|
||||
if (this._cascadeOpacityEnabled !== value) {
|
||||
this._cascadeOpacityEnabled = value;
|
||||
this._sgNode.cascadeOpacity = value;
|
||||
this._sgNode.setCascadeOpacityEnabled(value);
|
||||
this._onCascadeChanged();
|
||||
}
|
||||
},
|
||||
@@ -532,8 +532,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
});
|
||||
|
||||
var sgNode = this._sgNode = new _ccsg.Node();
|
||||
sgNode.retain();
|
||||
if (!cc.game._isCloning) {
|
||||
sgNode.cascadeOpacity = true;
|
||||
sgNode.setCascadeOpacityEnabled(true);
|
||||
}
|
||||
|
||||
this._dirtyFlags = DirtyFlags.ALL;
|
||||
@@ -548,6 +549,11 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
this._sizeProvider = null;
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
this._sgNode.release();
|
||||
this._super();
|
||||
},
|
||||
|
||||
// ABSTRACT INTERFACES
|
||||
|
||||
// called when the node's parent changed
|
||||
@@ -587,12 +593,6 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
}
|
||||
},
|
||||
|
||||
//Helper function used by `setLocalZOrder`. Don't use it unless you know what you are doing.
|
||||
_setLocalZOrder: function (localZOrder) {
|
||||
this._localZOrder = localZOrder;
|
||||
this._sgNode._localZOrder = localZOrder;
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Defines the oder in which the nodes are renderer. <br/>
|
||||
* Nodes that have a Global Z Order lower, are renderer first. <br/>
|
||||
@@ -1085,9 +1085,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
return this._sgNode.convertToWorldSpaceAR(nodePoint);
|
||||
},
|
||||
|
||||
_convertToWindowSpace: function (nodePoint) {
|
||||
return this._sgNode._convertToWindowSpace(nodePoint);
|
||||
},
|
||||
// _convertToWindowSpace: function (nodePoint) {
|
||||
// return this._sgNode._convertToWindowSpace(nodePoint);
|
||||
// },
|
||||
|
||||
/**
|
||||
* convenience methods which take a cc.Touch instead of cc.Vec2
|
||||
|
||||
@@ -5,6 +5,7 @@ var SceneGraphUtils = {
|
||||
removeSgNode: function () {
|
||||
var node = this._sgNode;
|
||||
if (node) {
|
||||
node.release();
|
||||
if (node._parent) {
|
||||
node._parent.removeChild(node);
|
||||
}
|
||||
|
||||
+3
-1
@@ -20,7 +20,9 @@ paths = {
|
||||
JSBSkipModules: [
|
||||
'../../cocos2d/core/CCGame',
|
||||
'../../cocos2d/core/textures/CCTexture2D',
|
||||
'../../cocos2d/core/sprites/CCSpriteFrame'
|
||||
'../../cocos2d/core/sprites/CCSpriteFrame',
|
||||
'../../cocos2d/core/platform/CCLoader',
|
||||
'../../cocos2d/core/platform/CCLoaders'
|
||||
],
|
||||
|
||||
test: {
|
||||
|
||||
+13
-1
@@ -1,3 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
cc.ParticleSystem.Mode = cc.Enum({
|
||||
/** The gravity mode (A mode) */
|
||||
@@ -317,7 +318,7 @@ cc.js.mixin(cc.path, {
|
||||
//removing all ../
|
||||
do {
|
||||
oldUrl = url;
|
||||
url = url.replace(this.normalizeRE, "");
|
||||
url = url.replace(this.normalizeRE, '');
|
||||
} while(oldUrl.length !== url.length);
|
||||
return url;
|
||||
},
|
||||
@@ -356,6 +357,17 @@ cc.EventTarget.call(cc.director);
|
||||
cc.js.addon(cc.director, cc.EventTarget.prototype);
|
||||
|
||||
// cc.Label
|
||||
cc._Label = cc.Label;
|
||||
cc.Label = function (string, fontHandle, type) {
|
||||
var label;
|
||||
if (type === cc.Label.Type.TTF) {
|
||||
label = cc._Label.createWithSystemFont(string, fontHandle, 40);
|
||||
}
|
||||
else if (type === cc.Label.Type.BMFont) {
|
||||
label = cc._Label.createWithBMFont(fontHandle, string);
|
||||
}
|
||||
return label;
|
||||
};
|
||||
cc.Label.Type = cc.Enum({
|
||||
TTF: 0,
|
||||
BMFont: 1
|
||||
|
||||
Reference in New Issue
Block a user