这样使用时会出问题:
auto label = label::create(你好,fonts/3.ttf,28);
最好的解决办法是使用外置的xml文档/plist文档储存中文字符(必须使用utf-8编码)
新建文档string.xml如下:
br>//apple//dtd plist 1.0//enhttp://www.apple.com/dtds/propertylist-1.0.dtd>
title
是男人就坚持20秒
new_game
新游戏
setting_game
设置
quit_game
退出
s
为什么这么难?!
每个key对应一个string
在使用时:
dictionary* dictionary = dictionary::createwithcontentsoffile(string.xml);
ccstring* str = (ccstring*)dictionary->objectforkey(s); //这里获取了字符串
const char* s = str->getcstring(); //类型转换
auto label = label::create(s,fonts/3.ttf,28);
也有这样使用的:
ttfconfig ttfconfig(fonts/3.ttf,28,glyphcollection::custom);
dictionary* dictionary = dictionary::createwithcontentsoffile(fonts/string.xml);
ccstring* str = (ccstring*)dictionary->objectforkey(s);
const char* s = str->getcstring();
label* label = label::createwithttf(ttfconfig, s, texthalignment::center);
