Book Image

Mastering Cocos2d Game Development

By : Alex Ogorek
Book Image

Mastering Cocos2d Game Development

By: Alex Ogorek

Overview of this book

Table of Contents (15 chapters)
Mastering Cocos2d Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 are simple, unformatted labels. How are these useful? The answer is, you can quickly get the prototype of your game going, and so you can better understand the flow of the game. Then, once it's ready, you can switch over to using BMFonts to make it...