0

I use a cclabelttf label to display text inside standard sprite images. It works fine in retina and non-retina, but the last line of the text gets cut-off sometimes in the 64 bit iPad air.

This was the code I used,

[CCLabelTTF labelWithString:text fontName:_font fontSize:_fontSize dimensions:dimensions hAlignment:kCCTextAlignmentCenter vAlignment:kCCVerticalTextAlignmentCenter lineBreakMode:kCCLineBreakModeWordWrap];

But when I changed the text to vertically align top, it started working again.

[CCLabelTTF labelWithString:text fontName:_font fontSize:_fontSize dimensions:dimensions hAlignment:kCCTextAlignmentCenter vAlignment:kCCVerticalTextAlignmentTop lineBreakMode:kCCLineBreakModeWordWrap];

Any idea what's going on ? I'd really like to have the center vertical align for my text. Any solution to make that happen ?

  • v2.x? Are you building the arm64 slice? If so, don't, cocos2d v2.x is not 64-bit compatible. In any case make sure all 32-64 bit conversion warnings are on and check them thoroughly. – CodeSmile Mar 18 '14 at 09:42
  • Yes, I am using cocos2d (2.1). And I am building the arm64 slice. I thought it was mandatory from apple to have optimized apps for 64 bit versions. I am using cocoapods to include cocos2d and the latest version automatically have the pod architecture to include arm64 – Nithin Haridas Mar 18 '14 at 11:32
  • Also I am using newline characters for multi-line rendering – Nithin Haridas Mar 18 '14 at 12:08
  • OK, so I had to make my app 32 bit in the end. Another option might have been, http://stackoverflow.com/questions/22363266/xcode-5-1-force-32-bit-compilation-for-a-cocos2d-iphone-v3-project – Nithin Haridas Mar 19 '14 at 12:00

1 Answers1

0

The way I solved this issue was similar to the cocos2dx version issue covered on this link. You have to round up the CGSize components using the ceilf();

open up the CCTexture2d.m and find this method;

- (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size

and add the following code;

dim.width = ceilf(dim.width);
dim.height = ceilf(dim.height);

right after;

dim = [string sizeWithFont:font
             constrainedToSize:boundingSize
                 lineBreakMode:NSLineBreakByWordWrapping];
Yucel_K
  • 688
  • 9
  • 17