Creating rich text
After creating Label
objects on screen, you can create some effects such as a drop shadow and an outline on them easily without having your own custom class. The Label
class can be used for applying the effects to these objects. However, note that not all label types support all effects.
How to do it...
Drop shadow
Here's how to create Label
with a drop shadow effect:
auto layer = LayerColor::create(Color4B::GRAY); this->addChild(layer); auto label = Label::createWithTTF("Drop Shadow", "fonts/Marker Felt.ttf", 40); label->setPosition(size/2); this->addChild(label); // shadow effect label->enableShadow();
Outline
Here's how to create Label
with an outline effect:
auto label = Label::createWithTTF("Outline", "fonts/Marker Felt.ttf", 40); label->setPosition(size/2); this->addChild(label); // outline effect label->enableOutline(Color4B::RED, 5);
Glow
Here's how to create Label
with a glow effect:
auto label...