Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

学习笔记之cocos2d-x2.1.1实现读取.plist文件(使用数组CCArray)

$
0
0
<?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>picture</key>
		<array>
			<string>1.png</string>
			<string>2.png</string>
			<string>3.png</string>		
		</array>
		<key>point</key>
		<array>
			<string>{200,300}</string>
			<string>{500,300}</string>
			<string>{800,300}</string>
		</array>
</dict>
</plist>

		//////////////////////////////////////////////////////////////////////////
		//SmallTools2
	        CCDictionary* plistDic = CCDictionary::createWithContentsOfFile("SmallTools2.plist");
		CCArray* picture_array = (CCArray*)plistDic->objectForKey("picture");
		CCArray* point_array = (CCArray*)plistDic->objectForKey("point");
		for (int i=0;i<picture_array->count();i++)
		{
			CCString* pi_string = (CCString*)picture_array->objectAtIndex(i);
			CCSprite* sprite = CCSprite::create(pi_string->getCString());
			CCString* point_string = (CCString*)point_array->objectAtIndex(i);
			CCPoint point = CCPointFromString(point_string->getCString());
			sprite->setPosition(ccp(point.x,point.y));
			this->addChild(sprite,1,++TagCount);
		}	
		//////////////////////////////////////////////////////////////////////////


作者:Nat_myron 发表于2013-3-30 13:45:42 原文链接
阅读:0 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>