为了能在cocos2d-x的文本标签中显示中文,一个是转换文件编码格式,另一种就是读取utf-8格式的xml文件。我选择了后者,其原因大家可以去搜索一下cocos2d-x显示中文,希望能够你给答案。不管怎么样,本篇是介绍cocos2d-x读取xml的内容。下面开始吧。
首先先看代码:
#include "CXmlStream.h" CXmlStream::CXmlStream(const char* dicFilename) { this->m_dictionary = CCDictionary::createWithContentsOfFile(dicFilename); } CXmlStream::~CXmlStream() { } const char* CXmlStream::GetStringByKey(const char* keyword) { return ((CCString*)(this->m_dictionary->objectForKey(keyword)))->m_sString.c_str(); } const char* CXmlStream::GetStringByKeyFromFile(const char* d