O'Reilly logo

Mastering Cocos2d Game Development by Alex Ogorek

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating buttons and text (labels)

If you want to place a line of text on the screen, you need to create a label. There are two types of labels in Cocos2d: CCLabelBMFont and CCLabelTTF. Bitmap Font labels are the fancy labels created with Glyph Designer, mentioned earlier in this book. TrueType Font labels are regular, unformatted text labels that use either a font file that's already on the phone or a file you've added to your project.

Tip

Note that if you have a label that often needs updating, for example, a score counter or a health value, it's more efficient to use BMFonts in those cases, even if the font is a plain white font and looks exactly the same in TTF format.

Let's get some text displayed – CCLabelTTF

As mentioned earlier, TTF labels ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required