现如今为
TextAtlas
setProperty(const std::string &stringValue, const std::string &
stringValue
, int itemWidth, int itemHeight, const std::string &startCharMap);
stringValue 显示的文本内容
stringValue 字符集文件
itemWidth 单个字符的宽度
itemHeight
单个字符的高度
startCharMap 首字符的内容
代码如下:
private
:
Size size;
#include
"ui/CocosGUI.h"
//******
using
namespace
cocos2d
::
ui
;
//******
size
=
Director
::
getInstance
()->
getWinSize
();
// auto text = TextAtlas::create("1234567890", "cocosui/labelatlas.png", 17, 22, "0");
auto text = TextAtlas :: create ();
// text->setProperty(const std::string &stringValue, const std::string &charMapFile, int itemWidth, int itemHeight, const std::string &startCharMap);
text-> setProperty ( "1234567890" , "cocosui/labelatlas.png" , 17 , 22 , "0" );
text-> setPosition ( Vec2 ( size . width / 2 , size . height / 2 ));
auto text = TextAtlas :: create ();
// text->setProperty(const std::string &stringValue, const std::string &charMapFile, int itemWidth, int itemHeight, const std::string &startCharMap);
text-> setProperty ( "1234567890" , "cocosui/labelatlas.png" , 17 , 22 , "0" );
text-> setPosition ( Vec2 ( size . width / 2 , size . height / 2 ));
addChild(text);