cocos2dx 3.0版本之前,我们一直都是用CCLabelTTF,CCLabelBMFont,CCLabelAtlas来创建文本标签,
但是!3.0版本放出来后...看到这里你心里是不是又颤抖了一下?别害怕嘛,我要说的是:
3.0版本出来后这些标签也都是还可以用的啦,只是说我们有了更好的选择。
---------------------------------------------------
cocos2dx3.0添加了一种新的文本标签,这种标签不同的地方有:使用freetype来使它在不同的平台上有相同的视觉效果;由于使用更快的缓存代理,它的渲染也将更加快速;同时它还提供了绘边、阴影等特性。
---------------------------------------------------
常用的接口一览(因为很多接口都与LabelTTFT等一样,所以就列一些我所了解的“异类”)
//创建普通的文本标签,效果和CCLabelTTF::create(...);一样。TTFConfig是什么?下面会介绍
static Label * create(const std::string& text, const std::string& fontName, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
TextVAlignment vAlignment = TextVAlignment::TOP);
//通过读取TTFConfig配置的方式创建标签,
static Label* createWithTTF(const TTFConfig& ttfConfig, const std::string& text, TextHAlignment alignment = TextHAlignment::LEFT, int lineWidth = 0);
//使用.fnt的方式创建标签,类似CCLabelBMFont:create();
static Label* createWithBMFont(const std::string& bmfontFilePath, const std::string& text,
const TextHAlignment& alignment = TextHAlignment::LEFT, int lineWidth = 0,
const Point& imageOffset = Point::ZERO);
//使用.png的方式创建标签,类似CCLabelAtlas::create();
static Label * createWithCharMap(const std::string&