From c4b48a4c897ff7b879d496690d1ba01f08dd1b21 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 29 Dec 2015 21:21:21 +0800 Subject: [PATCH] fix layout child anchor change issue. 1. fix base-node getBoundingBox issue --- cocos2d/core/components/CCLayout.js | 1 + cocos2d/core/utils/base-node.js | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/components/CCLayout.js b/cocos2d/core/components/CCLayout.js index dd4dae7716..b32fe35b3d 100644 --- a/cocos2d/core/components/CCLayout.js +++ b/cocos2d/core/components/CCLayout.js @@ -205,6 +205,7 @@ var Layout = cc.Class({ children.forEach(function(child) { child.on('size-changed', this._doLayoutDirty, this); child.on('position-changed', this._doLayoutDirty, this); + child.on('anchor-changed', this._doLayoutDirty, this); }.bind(this)); }, diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index 16447dc385..3d0ab9ef4d 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -887,10 +887,8 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @return {Rect} The calculated bounding box of the node */ getBoundingBox: function () { - var boundingBox = this._sgNode.getBoundingBox(); - boundingBox.width = this._contentSize.width; - boundingBox.height = this._contentSize.height; - return boundingBox; + var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); + return cc._rectApplyAffineTransformIn(rect, this.getNodeToParentTransform()); }, /**