我正在使用用Mac创建的plist文件运行Coco2D-X的particleWithFile()函数。使用"textureImageData“键将图像数据嵌入plist文件中。在Mac上运行良好,但在Windows上运行失败,在CCAssert(isOK)上,请参阅下面的Coco2D-X代码(CCParticleSystem.cpp):
char *textureData = (char*)valueForKey("textureImageData", dictionary);
CCAssert(textureData, "");
int dataLen = strlen(textureData);
if(dataLen != 0)
{
// if it fails, try to get it from the base64-gzipped data
int decodeLen = base64Decode((unsigned char*)textureData, (unsigned int)dataLen, &buffer);
CCAssert( buffer != NULL, "CCParticleSystem: error decoding textureImageData");
CC_BREAK_IF(!buffer);
int deflatedLen = ZipUtils::ccInflateMemory(buffer, decodeLen, &deflated);
CCAssert( deflated != NULL, "CCParticleSystem: error ungzipping textureImageData");
CC_BREAK_IF(!deflated);
image = new CCImage();
bool isOK = image->initWithImageData(deflated, deflatedLen);
CCAssert(isOK, "CCParticleSystem: error init image with Data");
CC_BREAK_IF(!isOK);
m_pTexture = CCTextureCache::sharedTextureCache()->addUIImage(image, fullpath.c_str());
}解码似乎成功通过,问题出在zlib的inflate()函数中,无法解压缩png文件。
有什么建议吗?
发布于 2012-07-08 21:39:08
好了,我找到问题了。
显然,我的资源不是png文件,而是tiff文件。所以Inflate()返回了一个正确的缓冲区( tiff文件-对我来说看起来太长了,所以我怀疑它是错误的),但initWithImageData()无法创建图像,因为windows上的Cocos2d-x不支持tiff。
发布于 2015-07-25 15:12:10
我遇到这个问题是因为我将CC_USE_TIFF设置为0。
在我将CC_USE_TIFF恢复为1之后,问题就解决了。
https://stackoverflow.com/questions/11351594
复制相似问题