From 14b51b2ef6b94cce316f29bbdabbfe5df108f74e Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Wed, 17 Feb 2016 16:37:21 +0800 Subject: [PATCH] fix layout reorder child issue. Fix https://github.com/cocos-creator/fireball/issues/1935 --- cocos2d/core/CCNode.js | 4 ++++ cocos2d/core/components/CCLayout.js | 1 + cocos2d/core/sprites/CCScale9Sprite.js | 4 ++-- cocos2d/core/utils/base-node.js | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index f3735a9b0a..129c2d90f9 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1178,6 +1178,10 @@ if (cc.sys.isNative) { * @param {cc.Event} event * @param {cc.Node} event.detail - child */ +/** + * @event child-reorder + * @param {cc.Event} event + */ /** * Note: This event is only emitted from the top most node whose active value did changed, * not including its child nodes. diff --git a/cocos2d/core/components/CCLayout.js b/cocos2d/core/components/CCLayout.js index 4adc88c9e7..2ac3f8d1db 100644 --- a/cocos2d/core/components/CCLayout.js +++ b/cocos2d/core/components/CCLayout.js @@ -285,6 +285,7 @@ var Layout = cc.Class({ this.node.on('anchor-changed', this._doLayoutDirty, this); this.node.on('child-added', this._childrenAddOrDeleted, this); this.node.on('child-removed', this._childrenAddOrDeleted, this); + this.node.on('child-reorder', this._doLayoutDirty, this); this._updateChildrenEventListener(); }, diff --git a/cocos2d/core/sprites/CCScale9Sprite.js b/cocos2d/core/sprites/CCScale9Sprite.js index bdc817a57f..6c2092f357 100644 --- a/cocos2d/core/sprites/CCScale9Sprite.js +++ b/cocos2d/core/sprites/CCScale9Sprite.js @@ -764,7 +764,7 @@ var fillQuadGeneratorRadial = { var yleft = center.y + tanAngle * (left - center.x); if(yleft > bottom && yleft < top) { intersectPoints[0] = intersectPoints[4]; - intersectPoints[5] = null; + intersectPoints[4] = null; intersectPoints[0].x = left; intersectPoints[0].y = yleft; } @@ -1319,4 +1319,4 @@ cc.Scale9Sprite.FillType = cc.Enum({ Vertical: 1, //todo implement this RADIAL:2, -}); \ No newline at end of file +}); diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index cc26480815..f546d3a14d 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -48,6 +48,7 @@ var COLOR_CHANGED = 'color-changed'; var OPACITY_CHANGED = 'opacity-changed'; var CHILD_ADDED = 'child-added'; var CHILD_REMOVED = 'child-removed'; +var CHILD_REORDER = 'child-reorder'; var ERR_INVALID_NUMBER = CC_EDITOR && 'The %s is invalid'; @@ -1364,6 +1365,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ if (cc.renderer) { cc.renderer.childrenOrderDirty = this._parent._sgNode._reorderChildDirty = true; } + this._parent.emit(CHILD_REORDER); } },