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.
CCLabelTTF
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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.