Creating system font labels
Firstly, we will explain how to create a label with system fonts. System fonts are the fonts already installed on your devices. Since they are already installed, there is no need to go through the installation process. Therefore we will skip the installation instructions for system fonts in this recipe, and dive directly into creating labels.
How to do it...
Here's how to create a label by specifying a system font. You can create a single-line label by using the following code:
auto label = Label::createWithSystemFont("Cocos2d-x", "Arial", 40); label->setPosition(size/2); this->addChild(label);
How it works...
You should use the Label
class to display strings by specifying a string, a system font, and the font size. The Label
class will display a string that is converted into an image. After creating a Label
instance, you can use it in the same way as you use Sprite
. Because Label
is also a Node, we can use properties such as actions...