Friday, 31 May 2013

How to create multi-line label: cocos2d

Creating multi-line labels in cocos2d is very simple as shown below:

CCLabelTTF *multiLineLabel = [CCLabelTTF labelWithString:@"It is possible to have multi-line text in a cocos2d label. Here is the code . "  
                                dimensions:CGSizeMake(300.0, 80.0) 
                                alignment:UITextAlignmentCenter 
                                lineBreakMode:UILineBreakModeTailTruncation 
                                fontName:@"Marker Felt"  fontSize:25];
    multiLineLabel.position = ccp(240, 140);
    multiLineLabel.color=ccc3(255, 0, 0);
    [self addChild:multiLineLabel z:20];

No comments:

Post a Comment