I have a CCLabelTTF with a dynamic text. Let’s say it has a maxsize of 200,200. I create it:
CCLabelTTF * label = [CCLabelTTF labelWithString:@"Hello!" dimensions:CGSizeMake(200,200) alignment:UITextAlignmentLeft lineBreakMode:UILineBreakModeWordWrap fontName:@"Helvetica" fontSize:15];
This works nicely.
But I have to put something right under, therefore I need to know the height of the text. I’ve tried label.texture.contentSize, label.contentSize. They both is 200,200.
What can I do here?
I’m using cocos2d 1.x
You can use NSString’s sizeWithFont methods.
This should tell you the exact size of the text.