krishna Babu
krishna Babu

Reputation: 203

Adding Text to CCSprite

How to add Text to CCSprite Object. I Have 7 Sprite objects now i want to add text to that Sprite Objects with different Text. and how to change that text.

Help me...

Upvotes: 0

Views: 1223

Answers (1)

cocos2dbeginner
cocos2dbeginner

Reputation: 2217

E.g. for one sprite:

//Make a CCLabelTFF
        CCLabelTTF *label1 = [CCLabelTTF labelWithString:@"text1" fontName:@"Arial" fontSize:25];

//add it to the sprite

[sprite1 addChild: label1];

If you need to create many labels than I would prefer to use a CCLabelBMFont (better performence)

        CCLabelBMFont* labelBMF1 = [CCLabelBMFont labelWithString:@"text1" fntFile:@"fntfile.fnt"];

[sprite1 addChild: labelBMF1];

Upvotes: 1

Related Questions