cocos2d-x 中文乱码问题

strings.plist放在项目Resource目录下(需另存为UTF-8),内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>data</key>
    <dict>
        <key>hello</key>
        <string>完美世界,完美生活</string>
        <key>cocos2d.x.display_fps</key>
        <true/>
        <key>cocos2d.x.gl.projection</key>
        <string>3d</string>
        <key>cocos2d.x.texture.pixel_format_for_png</key>
        <string>rgba8888</string>
        <key>cocos2d.x.texture.pvrv2_has_alpha_premultiplied</key>
        <false/>
    </dict>
    <key>metadata</key>
    <dict>
        <key>format</key>
        <integer>1</integer>
    </dict>
</dict>
</plist>

之后我们在自己的cocos2d-x项目导演类实例生成之前需要调用下面代码进行初始化操作:

CCConfiguration::sharedConfiguration()->loadConfigFile("strings.plist");

    一般我们在 AppDelegate::applicationDidFinishLaunching() 起始执行该部操作。之后就可以在程序中使用配置文件中的内容了:

CCConfiguration *conf = CCConfiguration::sharedConfiguration();
const char *helloStr = conf->getCString("hello", "unknown");
CCLabelTTF* pLabel = CCLabelTTF::create(helloStr, "Arial", 24);
pLabel->setPosition(ccp(200, 200));
this->addChild(pLabel, 1);



转自:http://www.cnblogs.com/sunguangran/archive/2013/07/29/3222660.html

posted @ 2014-09-18 19:31  猿走天下  阅读(431)  评论(0编辑  收藏  举报