O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

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

Adding text using CCLabel

In this section, we will take a look at how to add text to a scene. In Cocos2d, there are two ways in which we can add text: the CCLabelTTF way and the CCLabelBMFont way. We will look at CCLabelBMFont later in the book when we cover Glyph Designer in Chapter 9, Game Tools. For now, we will consider what CCLabels are and how they work.

Getting ready

CCLabelsTTF uses system fonts that are already present on our Mac system. So, additional work is required here. We will just call the name of the font, the text we want to display, and the size of the font, and we are good to go!

Note

Note that there may be cases where the font is installed on your system and it still isn't displayed in the game. This is because Cocos2d includes ...

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