From 444515710a44488416810b365695685b0aefa4a8 Mon Sep 17 00:00:00 2001 From: s1ddok Date: Sat, 6 Feb 2016 13:13:55 +0300 Subject: [PATCH] CCLayoutBox now takes into account a transform of a node issue #1333 --- cocos2d/CCLayoutBox.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) mode change 100644 => 100755 cocos2d/CCLayoutBox.m diff --git a/cocos2d/CCLayoutBox.m b/cocos2d/CCLayoutBox.m old mode 100644 new mode 100755 index d10cb856efe..ec5ebccfdb0 --- a/cocos2d/CCLayoutBox.m +++ b/cocos2d/CCLayoutBox.m @@ -44,7 +44,7 @@ - (void) layout float maxHeight = 0; for (CCNode* child in self.children) { - float height = child.contentSizeInPoints.height; + float height = [child boundingBox].size.height; if (height > maxHeight) maxHeight = height; } @@ -52,11 +52,11 @@ - (void) layout float width = 0; for (CCNode* child in self.children) { - CGSize childSize = child.contentSizeInPoints; + CGSize childSize = [child boundingBox].size; - CGPoint offset = child.anchorPointInPoints; + CGPoint offset = child.anchorPoint; CGPoint localPos = ccp(roundf(width), roundf((maxHeight-childSize.height)/2.0f)); - CGPoint position = ccpAdd(localPos, offset); + CGPoint position = ccpAdd(localPos, CGPointMake(offset.x * childSize.width, offset.y * childSize.height)); child.position = position; child.positionType = CCPositionTypePoints; @@ -78,7 +78,7 @@ - (void) layout float maxWidth = 0; for (CCNode* child in self.children) { - float width = child.contentSizeInPoints.width; + float width = [child boundingBox].size.width; if (width > maxWidth) maxWidth = width; } @@ -86,11 +86,11 @@ - (void) layout float height = 0; for (CCNode* child in self.children) { - CGSize childSize = child.contentSizeInPoints; + CGSize childSize = [child boundingBox].size; - CGPoint offset = child.anchorPointInPoints; + CGPoint offset = child.anchorPoint; CGPoint localPos = ccp(roundf((maxWidth-childSize.width)/2.0f), roundf(height)); - CGPoint position = ccpAdd(localPos, offset); + CGPoint position = ccpAdd(localPos, CGPointMake(offset.x * childSize.width, offset.y * childSize.height)); child.position = position; child.positionType = CCPositionTypePoints;