cocos2dx在VS2010里面直接写中文是没有问题的,问题在于运行后出来是乱码。真的很烦,网上有很多种方法,这里先说一种超简单的解决方法。
一、在Resources里面新建一个xml文件,记得用utf-8编码,内容如下:
<dict>
<key>str_action</key>
<string>动作</string>
<key>str_sprite</key>
<string>精灵</string>
<key>str_scene</key>
<string>场景</string>
</dict>
二、在需要显示中文的地方调用如下代码:
//读取存储文字的XML
CCDictionary *chnStrings = CCDictionary::createWithContentsOfFile("string_HelloWorldScene.xml");
//动作
const char *str_action=((CCString*)chnStrings->objectForKey("str_action"))->m_sString.c_str();//读到某一个Key的值
auto lb_action=CCLabelTTF::create(str_action,"Arial",35); //装成label