cocos2dx 3.3显示中文

前端之家收集整理的这篇文章主要介绍了cocos2dx 3.3显示中文前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在网上搜了好几个。。都是2.x的版本,不过变动不大,中文显示还是用的xml,只是api有些微变化@H_301_2@

前面的xml文件这些步骤跟2.x版本是相同的@H_301_2@

1.创建xml文件,如命名为CHNStrings.xml@H_301_2@

@H_301_2@
<dict>
@H_301_2@<key>language</key>
@H_301_2@<string>English</string>
@H_301_2@<key>username</key>
@H_301_2@<string>我是中文1ab</string>
@H_301_2@<key>website</key>
@H_301_2@<string>CSDN博客:http://blog.csdn.net/jackystudio</string>
</dict>@H_301_2@

2.使用xml文件显示中文@H_301_2@

@H_301_2@TTFConfig ttfConfig("fonts\\123.ttf",25);
@H_301_2@CCDictionary *chnStrings = CCDictionary::createWithContentsOfFile("CHN_Strings.xml"); @H_301_2@
@H_301_2@const char* username = ((CCString*)chnStrings->objectForKey("username"))->@H_301_2@@H_301_2@getCString(); auto labelTTF = Label::createWithTTF(ttfConfig,username); labelTTF->setColor(Color3B(255,255)); labelTTF->setPosition(300,500); pLayer->addChild(labelTTF);@H_301_2@ @H_301_2@

猜你在找的Cocos2d-x相关文章