Book Image

Building Android Games with Cocos2d-x

By : Raydelto Hernandez
Book Image

Building Android Games with Cocos2d-x

By: Raydelto Hernandez

Overview of this book

Table of Contents (16 chapters)
Building Android Games with Cocos2d-x
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating system fonts


You can create the labels that use the fonts of the host operating system; therefore, you would not be required to provide a font file. It is recommended that you use this kind of label only for testing purposes, since it would decrease the framework's flexibility because the selected font may not be available on the user's Android operating system version.

Just for the sake of testing, below our current text, we will add the following label in the init method of the GameOverScene.cpp implementation file:

auto label2 = Label::createWithSystemFont("Your score is", "Arial", 48);
label2->setPosition(origin.x + visibleSize.width/2,origin.y + visibleSize.height /2.5);
this->addChild(label2, 1);

This code yields the following result: