LabelTTF vertical alignment fixed on OS X

vertical alignment was broken on OS X.
top and bottom were switched.
This commit is contained in:
Ricardo Quesada 2013-06-11 14:59:40 -07:00 committed by minggo
parent 1780643c63
commit c1d519aac2
1 changed files with 7 additions and 4 deletions

View File

@ -373,7 +373,7 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
// alignment, linebreak // alignment, linebreak
unsigned uHoriFlag = eAlign & 0x0f; unsigned uHoriFlag = eAlign & 0x0f;
unsigned uVertFlag = (eAlign & 0xf0) >> 4; unsigned uVertFlag = (eAlign >> 4) & 0x0f;
NSTextAlignment align = (2 == uHoriFlag) ? NSRightTextAlignment NSTextAlignment align = (2 == uHoriFlag) ? NSRightTextAlignment
: (3 == uHoriFlag) ? NSCenterTextAlignment : (3 == uHoriFlag) ? NSCenterTextAlignment
: NSLeftTextAlignment; : NSLeftTextAlignment;
@ -441,8 +441,11 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
default: break; default: break;
} }
CGFloat yPadding = (1 == uVertFlag || realDimensions.height >= dimensions.height) ? 0 // align to top // 1: TOP
: (2 == uVertFlag) ? dimensions.height - realDimensions.height // align to bottom // 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 : (dimensions.height - realDimensions.height) / 2.0f; // align to center