字符串,标签和菜单
1.字符串
1.1 cocos2d::_String
_String是COCOS2D-X通用的一个字符串类,它的设计模拟了OC的NSString类。
主要有两个静态函数来创建它。create和createWithFormat
__String* __String::create(const std::string& str);
__String* __String::createWithFormat(const char* format, ...);
其它函数参照官方文档。
2.标签
2.1 标签类Label
Label类可以创建系统字体标签,TTF字体标签和位图字体标签(.png,.fnt)
具体函数代码如下
auto label1 = Label::createWithSystemFont("Hello World1", "Arial", 36);
label1->setPosition(Vec2(origin.x + visibleSize.width / 2,
origin.y + visibleSize.height - 100));
this->addChild(label1, 1);
auto label2 = Label::createWithTTF("Hello World2", "fonts/Marker Felt.ttf", 36);
label2->setPosition(Vec2(origin.x + visibleSize.width / 2,
origin.y + visibleSize.height - 200));
thi