- 將CCSprite存成檔案
- 存到相簿中
查了下資料,做法如下:
CCTexture2D *tx = [sprite1 texture]; //這邊是因為sprite1一直在更新,所以先copy
CCSprite *sprite = [CCSprite spriteWithTexture:tx];
sprite.anchorPoint = CGPointZero; //這個一定要有,尤其有更改過時
//先做成texture
CCRenderTexture *renderer = [CCRenderTexture renderTextureWithWidth:sprite.contentSize.width height:sprite.contentSize.height];
[renderer begin];
[sprite visit];
[renderer end];
UIImage *newImage = [renderer getUIImage];
//做成UIImage,就可以直接用UIImageWriteToSavedPhotosAlbum存檔UIImageWriteToSavedPhotosAlbum(newImage,nil,nil,nil);
參考網址:
UIImage from CCSprite (yes I've already searched)
UIImage轉CCTexture2D UIImage轉CCSprite
[IPHONE]將照片儲存到IOS照片相簿(Photo Album)中