From dd5c4cc72d09c7ab9baef3b80cfcb577ab431e62 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 29 Dec 2015 14:28:41 +0800 Subject: [PATCH] add basic layout logic --- cocos2d/core/components/CCLayout.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cocos2d/core/components/CCLayout.js b/cocos2d/core/components/CCLayout.js index 76c04e251e..e8ddaf5897 100644 --- a/cocos2d/core/components/CCLayout.js +++ b/cocos2d/core/components/CCLayout.js @@ -282,6 +282,20 @@ var Layout = cc.Class({ }.bind(this)); }, + _doLayoutBasic: function(layoutAnchor, layoutSize, children) { + // var allChildrenBoundingBox = null; + + // children.forEach(function(child){ + // if(!allChildrenBoundingBox){ + // allChildrenBoundingBox = child.getBoundingBoxToWorld(); + // } else { + // allChildrenBoundingBox = cc.rectUnion(allChildrenBoundingBox, child.getBoundingBoxToWorld()); + // } + // }); + + // this.node.setContentSize(cc.size(allChildrenBoundingBox.width, allChildrenBoundingBox.height)); + }, + _doLayout: function() { var children = this.node.children; var layoutAnchor = this.node.getAnchorPoint(); @@ -291,6 +305,8 @@ var Layout = cc.Class({ this._doLayoutHorizontally(layoutAnchor, layoutSize, children); } else if (this.layoutType === Type.VERTICAL) { this._doLayoutVertically(layoutAnchor, layoutSize, children); + } else if (this.layoutType === Type.BASIC) { + this._doLayoutBasic(layoutAnchor, layoutSize, children); } },