Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix render order for _replaceSgNode #51

Merged
merged 1 commit into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cocos2d/core/sprites/CCSpriteFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{

// SERIALIZATION

_serialize: function () {
_serialize: function (exporting) {
if (CC_EDITOR) {
var rect = this._rect;
var offset = this._offset;
Expand All @@ -525,7 +525,7 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
return {
name: this._name,
texture: uuid,
atlas: this._atlasUuid,
atlas: exporting ? this._atlasUuid : undefined, // strip from json if exporting
rect: [rect.x, rect.y, rect.width, rect.height],
offset: [offset.x, offset.y],
originalSize: [size.width, size.height],
Expand Down
89 changes: 45 additions & 44 deletions cocos2d/core/utils/base-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,50 +948,6 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
return null;
},

/**replace sgNode*/

_replaceSgNode: function(sgNode) {
if(sgNode instanceof _ccsg.Node) {
//apply property
var siblingIndex = this.getSiblingIndex();
sgNode.setPosition(this._position);
sgNode.setRotationX(this._rotationX);
sgNode.setRotationY(this._rotationY);
sgNode.setScale(this._scaleX, this._scaleY);
sgNode.setSkewX(this._skewX);
sgNode.setSkewY(this._skewY);

sgNode.setLocalZOrder(this._localZOrder);
sgNode.setGlobalZOrder(this._globalZOrder);

sgNode.setOpacity(this._opacity);
sgNode.setCascadeOpacityEnabled(this._cascadeOpacityEnabled);
sgNode.ignoreAnchorPointForPosition(this._ignoreAnchorPointForPosition);
sgNode.setTag(this._tag);
sgNode.setColor(this._color);
sgNode.setOpacityModifyRGB(this._opacityModifyRGB);

//rebuild scenegraph
var oldSgNode = this._sgNode;
var children = oldSgNode.getChildren().slice(0);
oldSgNode.removeAllChildren();

for(var index = 0; index < children.length; ++index) {
sgNode.addChild(children[index]);
}

var parentNode = oldSgNode.getParent();
parentNode.addChild(sgNode);
parentNode.removeChild(oldSgNode);
this.setSiblingIndex(siblingIndex);

this._sgNode = sgNode;

} else {
throw new Error("Invalid sgNode. It must an instance of _ccsg.Node");
}
},

// composition: ADD

/** <p>"add" logic MUST only be in this method <br/> </p>
Expand Down Expand Up @@ -1404,6 +1360,51 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
},

_removeSgNode: SceneGraphHelper.removeSgNode,

_replaceSgNode: function(sgNode) {
if(sgNode instanceof _ccsg.Node) {
var oldSgNode = this._sgNode;

//apply property
sgNode.setPosition(this._position);
sgNode.setRotationX(this._rotationX);
sgNode.setRotationY(this._rotationY);
sgNode.setScale(this._scaleX, this._scaleY);
sgNode.setSkewX(this._skewX);
sgNode.setSkewY(this._skewY);

sgNode.setLocalZOrder(this._localZOrder);
sgNode.setGlobalZOrder(this._globalZOrder);

sgNode.setOpacity(this._opacity);
sgNode.setCascadeOpacityEnabled(this._cascadeOpacityEnabled);
sgNode.ignoreAnchorPointForPosition(this._ignoreAnchorPointForPosition);
sgNode.setTag(this._tag);
sgNode.setColor(this._color);
sgNode.setOpacityModifyRGB(this._opacityModifyRGB);

//rebuild scenegraph
var children = oldSgNode.getChildren().slice(0);
oldSgNode.removeAllChildren();

for(var index = 0; index < children.length; ++index) {
sgNode.addChild(children[index]);
}

var parentNode = oldSgNode.getParent();
parentNode.removeChild(oldSgNode);

// insert node
parentNode.addChild(sgNode);
sgNode.arrivalOrder = oldSgNode.arrivalOrder;
cc.renderer.childrenOrderDirty = this._parent._sgNode._reorderChildDirty = true;

this._sgNode = sgNode;

} else {
throw new Error("Invalid sgNode. It must an instance of _ccsg.Node");
}
},
});


Expand Down
4 changes: 3 additions & 1 deletion extends.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ require('./cocos2d/core');
require('./cocos2d/animation');

require('./cocos2d/particle/CCParticleAsset');
require('./cocos2d/particle/CCEParticleSystem');

if (!(CC_EDITOR && Editor.isCoreLevel)) {

require('./cocos2d/particle/CCEParticleSystem');

if (cc.sys.isNative) {
// TODO - add to jsb ?
function log () {
Expand Down