下面看一下Data类
04
static const Data Null; |
06
Data(); |
08
Data(Data&& other); |
10
// 重载符号 |
11 |
Data& operator= (12 |
Data& operator= (Data&& other); |
14
unsignedchar * getBytes() ; |
16
voidcopy(unsigned * bytes, ssize_t size); |
17 |
fastSet(unsigned//从bytes快速set,使用后bytes将不能在外部使用 |
18
clear(); |
20
private: |
22
23 |
* _bytes; |
24
ssize_t _size; |
unsigned char* getFileDataFromZip(const std::string& zipFilePath,const std::string& filename,ssize_t *size);//读取压缩文件数据(zip格式)
如果读取成功size中会返回文件的大小,否则返回0。
std::string fullPathForFilename(const std::string &filename);//获取文件的完整路径
如果我们通过setSearchPaths()设置搜索路径("/mnt/sdcard/","internal_dir/"),然后通过setSearchResolutionsOrder()设置子区分路径("resources-ipadhd/","resources-ipad/","resources-iphonehd")。如果搜索文件名为'sprite.png' 那么会先在文件查找字典中查找key: sprite.png -> value: sprite.pvr.gz,然后搜索文件'sprite.pvr.gz'如下顺序:
1
/mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found,search next) |
2
/mnt/sdcard/resources-ipad/sprite.pvr.gz (
3 |
/mnt/sdcard/resources-iphonehd/sprite.pvr.gz (4 |
/mnt/sdcard/sprite.pvr.gz (5 |
internal_dir/resources-ipadhd/sprite.pvr.gz (6 |
internal_dir/resources-ipad/sprite.pvr.gz (7 |
internal_dir/resources-iphonehd/sprite.pvr.gz (8 |
internal_dir/sprite.pvr.gz (return "sprite.png" ) |
如果找到返回完整路径,没找到返回'sprite.png'。
void loadFilenameLookupDictionaryFromFile(const std::string &filename);//从文件导入文件名查找字典
文件为plist格式如下:
<?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"
>
<dict>
<key>sounds/click.wav</key>
<string>sounds/click.caf</string>
<key>sounds/endgame.wav</key> |
<string>sounds/endgame.caf</string>
<key>sounds/gem-0.wav</key> |
<string>sounds/gem-0.caf</string>
<key>version</key>
</dict>