Merge pull request #739 from natural-law/issue3170

Solve the issue : Can't reorder the children of TiledMap nodes.
This commit is contained in:
Jare Guo
2016-05-27 11:57:01 +08:00
+10 -13
View File
@@ -443,7 +443,7 @@ var TiledMap = cc.Class({
this.node.on('anchor-changed', this._anchorChanged, this);
this.node.on('child-added', this._childAdded, this);
this.node.on('child-reorder', this._reorderChildren, this);
this.node.on('child-reorder', this._syncChildrenOrder, this);
},
onDisable: function () {
@@ -458,7 +458,7 @@ var TiledMap = cc.Class({
this.node.off('anchor-changed', this._anchorChanged, this);
this.node.off('child-added', this._childAdded, this);
this.node.off('child-reorder', this._reorderChildren, this);
this.node.off('child-reorder', this._syncChildrenOrder, this);
},
onDestroy: function() {
@@ -642,7 +642,7 @@ var TiledMap = cc.Class({
}
// reorder the children
this._reorderChildren();
this._syncChildrenOrder();
},
_anchorChanged: function() {
@@ -672,21 +672,18 @@ var TiledMap = cc.Class({
}
},
_reorderChildren: function() {
_syncChildrenOrder: function() {
var logicChildren = this.node.children;
for (var i = 0, n = logicChildren.length; i < n; i++) {
var child = logicChildren[i];
var tmxLayer = child.getComponent(cc.TiledLayer);
var zOrderValue = child.getSiblingIndex();
child.setLocalZOrder(zOrderValue);
if (tmxLayer) {
if (tmxLayer._sgNode) {
tmxLayer._sgNode.setLocalZOrder(zOrderValue);
}
} else {
if (child._sgNode) {
child._sgNode.setLocalZOrder(zOrderValue);
}
if (tmxLayer && tmxLayer._sgNode) {
tmxLayer._sgNode.setLocalZOrder(zOrderValue);
}
if (child._sgNode) {
child._sgNode.setLocalZOrder(zOrderValue);
}
}
},