Android 使用cocos2d-x加载zip时发生崩溃
我在android上使用cocos2d-x时遇到问题。 我正在尝试使用加载.zip文件Android 使用cocos2d-x加载zip时发生崩溃,android,cocos2d-x,Android,Cocos2d X,我在android上使用cocos2d-x时遇到问题。 我正在尝试使用加载.zip文件 CCFileUtils::sharedFileUtils()->getFileDataFromZip(...) 由于这个项目是设计成多平台的,我们也在iPad3上尝试了这段代码,它在那里工作没有问题。 问题是,应用程序在加载zip文件时出现分段错误 下面是完整的代码和一些额外的注释 void Map::loadChunk(int index, CCPoint startPoint) { chu
CCFileUtils::sharedFileUtils()->getFileDataFromZip(...)
由于这个项目是设计成多平台的,我们也在iPad3上尝试了这段代码,它在那里工作没有问题。
问题是,应用程序在加载zip文件时出现分段错误
下面是完整的代码和一些额外的注释
void Map::loadChunk(int index, CCPoint startPoint) {
chunks[index]->startPoint = startPoint;
std::stringstream filename;
filename << (int)startPoint.x << "_" << (int)startPoint.y << ".map";
unsigned long filesize = 0;
const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("map1.zip");
CCLog(path);
CCLog(filename.str().c_str());
// In the following two lines the error occurs
const char* buffer =(const char*) CCFileUtils::sharedFileUtils()->getFileDataFromZip(path, filename.str().c_str(), &filesize);
std::istringstream fileBuffer(buffer);
CCLog("filesize %d", (int)filesize);
std::string line;
// Here some code follows but this code does not produce the problem so I left it out
}
void Map::loadChunk(int索引,CCPoint-startPoint){
块[index]->startPoint=startPoint;
std::stringstream文件名;
文件名我已经弄明白了为什么这不起作用
将另一个.zip打包到.apk中似乎是个问题。
在收到的文件夹中播放.zip时
CCFileUtils::sharedFileUtils()->getWriteablePath()
然后用手打开拉链
CCFileUtils::sharedFileUtils()->getFileDataFromZip(...)
zip正确加载,我能够从zip内部读取某些文件
CCFileUtils::sharedFileUtils()->getFileDataFromZip(...)