I'm trying to create CCLabelTTF
where the text changes as the story progresses, but I'm having trouble setting a simple piece of text to it. The label currently displays (null) and I can't seem get it to display "This is text". NSLog
returns it properly, but the label won't display it. I also made sure the label wasn't destroyed. Here is the code:
CGSize narrativeTextSize;
narrativeTextSize.width=740;
narrativeTextSize.height=60;
CCLabelTTF *narrativeTextLabel =[CCLabelTTF labelWithString:[NSString
stringWithFormat:@"%@", narrativeText]
dimensions:narrativeTextSize
hAlignment:UITextAlignmentLeft
lineBreakMode:UILineBreakModeWordWrap
fontName:@"Helvetica"
fontSize:20];
narrativeTextLabel.position = ccp(255,60);
narrativeText = @"This is text";
//NSLog(@"%@", narrativeText);
[gameMenu addChild:narrativeTextLabel];
Just write
narrativeText = @"This is text";
above CCLabelTTF *narrativeTextLabel
... line.