Using bitmap fonts for better performance

As we've seen before, CCLabelTTF is very easy to use, but we also must be aware of its drawbacks; the biggest one of which is its poor performance. Fortunately, we have an alternative way of rendering text with the help of bitmap fonts and the CCLabelBMFont class in Cocos2D.

What are bitmap fonts? Well, since OpenGL can't draw text natively, but it surely can draw images very well, it is obvious that we can use images to represent our text. We can simply create an image containing all letters, and then when we need to write some text, we just draw each letter in its place on the screen.

Note

To visualize this process, just recall some movie where an evil guy cuts letters from newspapers and magazines to create ...

Get Learning iPhone Game Development with Cocos2D 3.0 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.