Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cocos2d-x cookbook

You're reading from   Cocos2d-x cookbook Over 50 hands-on recipes to help you efficiently administer and maintain your games with Cocos2d-x

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher
ISBN-13 9781783284757
Length 254 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Akihiro Matsuura Akihiro Matsuura
Author Profile Icon Akihiro Matsuura
Akihiro Matsuura
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Cocos2d-x FREE CHAPTER 2. Creating Sprites 3. Working with Labels 4. Building Scenes and Layers 5. Creating GUIs 6. Playing Sounds 7. Working with Resource Files 8. Working with Hardware 9. Controlling Physics 10. Improving Games with Extra Features 11. Taking Advantages Index

Creating bitmap font labels

Lastly, we will explain how to create a label with bitmap type fonts. Bitmap fonts are also fonts that you can install into your project. A bitmap font is essentially an image file that contains a bunch of characters and a control file that details the size and location of each character within the image. If you use bitmap fonts in your game, you can see that the bitmap fonts will be the same size on all devices.

Getting ready

You have to prepare a bitmap font. You can create it by using a tool such as GlyphDesigner. We will explain this tool after Chapter 10, Improving Games with Extra Features. Now, we will use a bitmap font in Cocos2d-x. It is located in the COCOS_ROOT/tests/cpp-tests/Resources/fonts folder. To begin with, you will have to add the files mentioned below to your Resources/fonts folder in your project.

  • future-48.fnt
  • future-48.png

How to do it...

Here's how to create a label by specifying a bitmap font. The following code can be used for creating...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image