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

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3. <plist version="1.0">
  4. <dict>
  5. <key>picture</key>
  6. <array>
  7. <string>1.png</string>
  8. <string>2.png</string>
  9. <string>3.png</string>
  10. </array>
  11. <key>point</key>
  12. <array>
  13. <string>{200,300}</string>
  14. <string>{500,300}</string>
  15. <string>{800,300}</string>
  16. </array>
  17. </dict>
  18. </plist>
  1. //////////////////////////////////////////////////////////////////////////
  2. //SmallTools2
  3. CCDictionary* plistDic = CCDictionary::createWithContentsOfFile("SmallTools2.plist");
  4. CCArray* picture_array = (CCArray*)plistDic->objectForKey("picture");
  5. CCArray* point_array = (CCArray*)plistDic->objectForKey("point");
  6. for (int i=0;i<picture_array->count();i++)
  7. {
  8. CCString* pi_string = (CCString*)picture_array->objectAtIndex(i);
  9. CCSprite* sprite = CCSprite::create(pi_string->getCString());
  10. CCString* point_string = (CCString*)point_array->objectAtIndex(i);
  11. CCPoint point = CCPointFromString(point_string->getCString());
  12. sprite->setPosition(ccp(point.x,point.y));
  13. this->addChild(sprite,1,++TagCount);
  14. }
  15. //////////////////////////////////////////////////////////////////////////

cocos2d-实现读取.plist文件(使用数组CCArray)的更多相关文章

  1. cocos2d-x 读取.plist文件

    转自:http://blog.csdn.net/hgplan/article/details/8629904 在cocos2d-x中可以用.plist格式的文件来保存数据,它是XML文件格式的一种,在 ...

  2. 黑马程序员——读取Plist文件

    -iOS培训,iOS学习-------型技术博客.期待与您交流!------------ 读取Plist文件     一:新建一个plist文件,并将plist文件数据填入plist文件中,这里pli ...

  3. cocos2d-x 2.1 -- 读取.plist文件

    在cocos2d-x中可以用.plist格式的文件来保存数据,它是XML文件格式的一种,在cocos2d-x解析.plist方面相关的资料比较少,但本身也很简单,要解析.plist文件可以参考coco ...

  4. PHP读取txt文件到数组

    $file_path = "test.txt"; if(file_exists($file_path)){ $file_arr = file($file_path); for($i ...

  5. iOS开发读取plist文件、iphone中plist文件的

    在Xcode中建立一个iOS项目后,会自己产生一个.plist文件,点击时会看见它显示的是类似于excel表格: 但是,如果打开方式选择Source Code,你会看见它其实是一个xml文件. 我们会 ...

  6. [How to]如何自定义plist文件和读取plist文件内容

    1.简介 plist作为IOS的固化文件,就好比java中properties文件,但是在IOS中plist是可读写的. 本文将介绍自定义静态的plist文件. 2.自定义静态plist文件 右击你的 ...

  7. 解决pathForResource返回nil, 无法读取plist文件问题

    有很多人在设置plist文件的时候, 会发现读取不了plist文件里面的内容, 返回值为nil, 下面我们来解决一下这个问题. 首先我们打开工程并且按照下面的步骤来设置: 设置好后, 我们来写一段代码 ...

  8. iOS-如何读取Plist文件

    解决办法: // 1) 找到Plist文件的路径 "path" NSString *path = [[NSBundle mainBundle]pathForResource:@&q ...

  9. PHP excel读取excel文件转换为数组

    /*备注:先去下载PHP EXCEL——http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=phpexcel&am ...

随机推荐

  1. JAVA GUI学习 - JFileChooser文件选择器组件学习:未包括JFileChooser系统类学习

    public class JFileChooserKnow { /** * @param args */ public static void main(String[] args) { // TOD ...

  2. 浅谈CSS布局

    在No.4中谈及了下盒子模型,引出布局模型 1.布局模型有三类: 1)流动模型  flow(默认) 2)浮动模型  float 3)层模型  layer 2.文档流 :指的是文本沿着从左到右的方向展开 ...

  3. 简单JSONP跨域请求

    JSONP原理:利用<script>标签的src属性实现跨域的请求.可在URL中提供回调函数的名字.后台进过处理后将数据以回调函数参数的形式返回. demo:JSONP请求不同端口的数据 ...

  4. tomcat使用所遇到的问题

    1.在使用eclipse添加server的时候添加不了tomcat服务器: 如图左图所示,添加按钮已成灰色,无法操作. 解决办法:找到workspace的工作空间->.metadata-> ...

  5. ansible笔记

    ansible 资料 ansible 配置 ansible inventory配置文件 ansible模块 http://www.cnblogs.com/iois/p/6216936.html ans ...

  6. 织梦dedecms|文章模型内容页标签

    文章标题:{dede:field.title/}文章链接:{dede:field name='arcurl'/}发布时间:{dede:field.pubdate function="MyDa ...

  7. graph isomorphism 开源算法库VFlib, Nauty

    VFlib 开源算法库网站:http://www.cs.sunysb.edu/~algorith/implement/vflib/implement.shtml Nauty 开源算法库网站:http: ...

  8. struts OGNL数据标签

    OGNL对象图导航语言,类似于el表达式,strut的底层就是用这个写的在导入struts-core的时候会导入ognl.jar public class Test { public static v ...

  9. android 破解九宫格

    将目录切换到D:/adb目录下,命令如下 敲入命令 adb shell 然后回车,可以见到如下结果 再敲入命令cd /data/system然后回车, 再执行 rm gesture.key 回车,搞定 ...

  10. MySQL server has gone away 解决方法

    应用程序(比如PHP)长时间的执行批量的MYSQL语句.执行一个SQL,但SQL语句过大或者语句中含有BLOB或者longblob字段.比如,图片数据的处理.都容易引起MySQL server has ...