O'Reilly logo

Cocos2d-x Cookbook by Akihiro Matsuura

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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();
Drop shadow

Outline

Here's how to create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required