mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
Merge pull request #739 from natural-law/issue3170
Solve the issue : Can't reorder the children of TiledMap nodes.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user