Book Image

Learning iPhone Game Development with Cocos2D 3.0

By : Kirill Muzykov
Book Image

Learning iPhone Game Development with Cocos2D 3.0

By: Kirill Muzykov

Overview of this book

Table of Contents (19 chapters)
Learning iPhone Game Development with Cocos2D 3.0
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 anonymous threating letters. The only difference is that we have an unlimited number of each letter because nothing is really cut.

Also, as we already know drawing images one by one is a pretty expensive operation, so it would be better to group...