From 75b9913c9279eeda61678c6dcea0bf18c2d0481c Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 11 Jun 2013 14:59:40 -0700 Subject: [PATCH] LabelTTF vertical alignment fixed on OS X vertical alignment was broken on OS X. top and bottom were switched. --- cocos2dx/platform/mac/CCImage.mm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cocos2dx/platform/mac/CCImage.mm b/cocos2dx/platform/mac/CCImage.mm index 4f46521b2b..16f6ee9a00 100755 --- a/cocos2dx/platform/mac/CCImage.mm +++ b/cocos2dx/platform/mac/CCImage.mm @@ -373,7 +373,7 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl // alignment, linebreak unsigned uHoriFlag = eAlign & 0x0f; - unsigned uVertFlag = (eAlign & 0xf0) >> 4; + unsigned uVertFlag = (eAlign >> 4) & 0x0f; NSTextAlignment align = (2 == uHoriFlag) ? NSRightTextAlignment : (3 == uHoriFlag) ? NSCenterTextAlignment : NSLeftTextAlignment; @@ -440,9 +440,12 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl case NSRightTextAlignment: xPadding = dimensions.width-realDimensions.width; break; default: break; } - - CGFloat yPadding = (1 == uVertFlag || realDimensions.height >= dimensions.height) ? 0 // align to top - : (2 == uVertFlag) ? dimensions.height - realDimensions.height // align to bottom + + // 1: TOP + // 2: BOTTOM + // 3: CENTER + CGFloat yPadding = (1 == uVertFlag || realDimensions.height >= dimensions.height) ? (dimensions.height - realDimensions.height) // align to top + : (2 == uVertFlag) ? 0 // align to bottom : (dimensions.height - realDimensions.height) / 2.0f; // align to center