zoukankan      html  css  js  c++  java
  • cocos2dx plist使用

      windows下通过TexturePacker将单个的sprite放入

      导出 niao.png        和         niao.plist

    View Code
     1 <?xml version="1.0" encoding="UTF-8"?>
    2 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    3 <plist version="1.0">
    4 <dict>
    5 <key>frames</key>
    6 <dict>
    7 <key>xiangsique_feixiang_001.png</key>
    8 <dict>
    9 <key>frame</key>
    10 <string>{{0,73},{47,73}}</string>
    11 <key>offset</key>
    12 <string>{2,0}</string>
    13 <key>rotated</key>
    14 <true/>
    15 <key>sourceColorRect</key>
    16 <string>{{4,0},{47,73}}</string>
    17 <key>sourceSize</key>
    18 <string>{51,73}</string>
    19 </dict>
    20 <key>xiangsique_feixiang_002.png</key>
    21 <dict>
    22 <key>frame</key>
    23 <string>{{0,0},{47,73}}</string>
    24 <key>offset</key>
    25 <string>{2,0}</string>
    26 <key>rotated</key>
    27 <false/>
    28 <key>sourceColorRect</key>
    29 <string>{{4,1},{47,73}}</string>
    30 <key>sourceSize</key>
    31 <string>{51,75}</string>
    32 </dict>
    33 </dict>
    34 <key>metadata</key>
    35 <dict>
    36 <key>format</key>
    37 <integer>2</integer>
    38 <key>realTextureFileName</key>
    39 <string>yingwu.png</string>
    40 <key>size</key>
    41 <string>{128,128}</string>
    42 <key>textureFileName</key>
    43 <string>yingwu.png</string>
    44 </dict>
    45 </dict>
    46 </plist>

      将niao.png和niao.plist放入visual studio的 Resources目录下。

    1 CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("niao.plist");
    2
    3 eagle_sprite_->initWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("xiangsique_feixiang_001.png"));

      在plist中只需要管sprite的<key>xiangsique_feixiang_001.png</key>

      使用合成的png加plist的好处:目前使用的比较少没啥感觉,现在看来最明显的好处就是不让png文件很多很杂乱; 这个待补充。

      好处:
      1.Reduced OpenGL ES bind calls-the more images contained the textrue atlas, the greater the reduction.
      2.Reduced memory footprint for the images stored as textrue in memory.
      3.Easy method to trim and save on transparent apace in your images,allowing for more images/texture in the same apace.
      4.Zwoptex and TexturePacker are fully supported by cocos2d, so creating and using texture atlases is painless. 

    write by fgd

  • 相关阅读:
    js简单验证码的生成和验证
    基本够用的php.ini配置文件(CentOS7)
    转发:CentOS下tar压缩排除某个文件夹或文件及解压
    阿里云服务器CentOS7 vsftp安装、设置及后台端口的设置
    转发:entos7修改文件夹权限和用户名用户组
    转发:查看centos中的用户和用户组
    阿里云服务器CentOS7怎么分区格式化/挂载硬盘
    php调试用的几个小方法
    Jquery实现日期转换为 Unix时间戳及时间戳转换日期
    Jquery计算时间戳之间的差值,可返回年,月,日,小时等
  • 原文地址:https://www.cnblogs.com/wendao/p/egn_cocos2dx_plist.html
Copyright © 2011-2022 走看看