学习札记之cocos2d-x2.1.1实现读取.plist文件(使用数组CCArray)
- <?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>
-
-
- 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);
- }
-