有谁知道如何将 UIImage 转换为 cocos2d-x CCSprite。我最近的尝试是: 1. 在手机上将 UIImage 存储为 png 2. 将 png 加载为 CCSprite
[UIImagePNGRepresentation(photo) writeToFile:imagePath atomically:true];
CCSprite *sprite = CCSprite::spriteWithFile(imagePath);
但这在 CCObject 保留功能中崩溃了
void CCObject::retain(void)
{
CCAssert(m_uReference > 0, "reference count should greater than 0");
++m_uReference;
}
而且我不明白 Walzer Wang 的建议是如何工作的 http://cocos2d-x.org/boards/6/topics/3922
CCImage::initWithImageData(void* pData, int nDataLen, ...)
CCTexture2D::initWithImage(CCImage* uiImage);
CCSprite::initWithTexture(CCTexture2D* pTexture);