6. Text, Fonts, and the Written Word

In the last two chapters, you learned how to add artificial intelligence, animations, and enemies to your game. In this chapter you get to have a reprieve from the complexities of game mechanics and focus on the text rendering available in Cocos2D. Cocos2D has extensive support for all of the built-in iOS fonts as well as embedded TrueType fonts. The text system allows you to add labels and text to your game with ease.

The font-rendering system in Cocos2D is split into two portions or classes: the CCLabelTTF and the CCLabelBMFont classes. This chapter covers both classes and how to use them in Space Viking.


The CCLabelTTF class is meant as a quick and easy way to get text into your game with a minimal ...

Get Learning Cocos2D: A Hands-On Guide to Building iOS Games with Cocos2D, Box2D, and Chipmunk now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.