Home  >  Article  >  Database  >  一步教你在 cocos2d

一步教你在 cocos2d

WBOY
WBOYOriginal
2016-06-07 15:31:111279browse

时间: 2012.4.10 平台: vs2010, cocos2d-x *.12.* , tinyxml:2.6.2 其中:tinyxml 下载:http://sourceforge.net/projects/tinyxml/files/ tinyxml相关网页: www.sourceforge.net/projects/tinyxml Original code by Lee Thomason (www.grinninglizard.com) 本

时间: 2012.4.10

平台: vs2010, cocos2d-x *.12.* , tinyxml:2.6.2

其中:tinyxml 下载:http://sourceforge.net/projects/tinyxml/files/

tinyxml相关网页:

www.sourceforge.net/projects/tinyxml
Original code by Lee Thomason (www.grinninglizard.com)

本文假定你已经配置好cocos2d-x;

新建工程

将一下文件导入到classes目录

一步教你在 cocos2d

建立一个 test.xml

<?xml version="1.0" encoding="utf-8"?>
<document>
  <level name="difficulity" value="Easy">First Level</level>
  <level name="difficulity" value="Normal">Second Level</level>
</document>

将这个xml文件放到Resource目录下;

然后开始读取吧:(首先包括头文件 #include "tinyxml.h")

	TiXmlDocument* xmlDoc = new TiXmlDocument(CCFileUtils::fullPathFromRelativePath("test.xml"));
	xmlDoc->LoadFile();
	TiXmlElement* rootElement = xmlDoc->RootElement();
	CCLog("%s", rootElement->Value());
	TiXmlElement* firstElement = rootElement->FirstChildElement();
	TiXmlElement* secondElement = firstElement->NextSiblingElement();
	CCLog("firstElement:%s secondElement:%s", firstElement->GetText(), secondElement->GetText());
	delete xmlDoc;


 

ok,很easy吧。

 

http://blog.csdn.net/hoyt00/article/details/6769883

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn